From 1377bb232a5efeab36463431b63f49d29a4ad268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:19:58 +0000 Subject: [PATCH 001/114] Auto-generated commit 88989fbf9df453fd9d65cbf0f2f572506922fc54 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 236 +++++ index.d.ts | 505 ++++++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 33 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3978 insertions(+) create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README.md create mode 100644 index.d.ts create mode 100644 index.mjs create mode 100644 index.mjs.map create mode 100644 package.json create mode 100644 stats.html diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..e5c896d --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,28 @@ +# This file is generated by tools/scripts/update_contributors. +# +# Contributors listed in alphabetical order. + +Ali Salesi +Athan Reines +Brendan Graetz +Bruno Fenzl +Christopher Dambamuromo +Dominik Moritz +Frank Kovacs +James +Jithin KS +Joey Reed +Joris Labie +Justin Dennison +Marcus +Matt Cochrane +Milan Raj +Momtchil Momtchev +Ognjen Jevremović +Philipp Burckhardt +Ricky Reusser +Ryan Seal +Seyyed Parsa Neshaei +Shraddheya Shendre +dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> +rei2hu diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcc9934 --- /dev/null +++ b/LICENSE @@ -0,0 +1,481 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by this +license (the "Software") to use, reproduce, display, distribute, execute, and +transmit the Software, and to prepare derivative works of the Software, and to +permit third-parties to whom the Software is furnished to do so, all subject to +the following: + +The copyright notices in the Software and this entire statement, including the +above license grant, this restriction and the following disclaimer, must be +included in all copies of the Software, in whole or in part, and all derivative +works of the Software, unless such copies or derivative works are solely in the +form of machine-executable object code generated by a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES +OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + +DEPENDENCIES + +The library links against the following external libraries, which have their own +licenses: + +* OpenBLAS + +Copyright (c) 2011-2014, The OpenBLAS Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* Electron + +Copyright (c) 2013-2017 GitHub Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +* Cephes + +Copyright (c) 1984-2000 Stephen L. Moshier + +Some software in this archive may be from the book _Methods and Programs for +Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) +or from the Cephes Mathematical Library, a commercial product. In either event, +it is copyrighted by the author. What you see here may be used freely but it +comes with no support or guarantee. + +Stephen L. Moshier +moshier@na-net.ornl.gov + + + +ATTRIBUTION + +The library contains implementations from the following external libraries, +which have their own licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* FDLIBM + +Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* Go + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* SLATEC Common Mathematical Library + +Public domain. + + +* ESLint + +Copyright JS Foundation and other contributors, https://js.foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +* StatsFuns.jl + +Copyright (c) 2015: Dahua Lin. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* SpecialFunctions.jl + +The MIT License (MIT) + +Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others: + +https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +* MT19937 + +Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..10e6ba1 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2016-2022 The Stdlib Authors. diff --git a/README.md b/README.md new file mode 100644 index 0000000..956db97 --- /dev/null +++ b/README.md @@ -0,0 +1,236 @@ + + +# zeros + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a zero-filled [ndarray][@stdlib/ndarray/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes]. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; +``` + +#### zeros( shape\[, options] ) + +Creates a zero-filled [ndarray][@stdlib/ndarray/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes]. + +```javascript +var arr = zeros( [ 2, 2 ] ); +// returns + +var sh = arr.shape; +// returns [ 2, 2 ] + +var dt = arr.dtype; +// returns 'float64' +``` + +The specified output [ndarray][@stdlib/ndarray/ctor] `shape` may be either an array-like object or an integer value. + +```javascript +var arr = zeros( 2 ); +// returns + +var sh = arr.shape; +// returns [ 2 ] + +var dt = arr.dtype; +// returns 'float64' +``` + +The function accepts the following `options`: + +- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Default: `'float64'`. +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. + +By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [`float64`][@stdlib/ndarray/dtypes] data type. To specify an alternative [data type][@stdlib/ndarray/dtypes], provide a `dtype` option. + +```javascript +var arr = zeros( [ 2, 2 ], { + 'dtype': 'float32' +}); +// returns + +var sh = arr.shape; +// returns [ 2, 2 ] + +var dt = arr.dtype; +// returns 'float32' +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```html + + + + + + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + +
+ +* * * + +## Notice + +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]. + +#### Community + +[![Chat][chat-image]][chat-url] + +--- + +## License + +See [LICENSE][stdlib-license]. + + +## Copyright + +Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. + +
+ + + + + + + + diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..f316c7d --- /dev/null +++ b/index.d.ts @@ -0,0 +1,505 @@ +/* +* @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. +*/ + +// TypeScript Version: 2.0 + +/// + +import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + * + * ## Notes + * + * - If provided, this option overrides the input array's inferred order. + */ + order?: Order; +} + +/** +* Interface describing function options. +*/ +interface Float64Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'float64'; +} + +/** +* Interface describing function options. +*/ +interface Float32Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'float32'; +} + +/** +* Interface describing function options. +*/ +interface Complex128Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'complex128'; +} + +/** +* Interface describing function options. +*/ +interface Complex64Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'complex64'; +} + +/** +* Interface describing function options. +*/ +interface Int32Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'int32'; +} + +/** +* Interface describing function options. +*/ +interface Int16Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'int16'; +} + +/** +* Interface describing function options. +*/ +interface Int8Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'int8'; +} + +/** +* Interface describing function options. +*/ +interface Uint32Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'uint32'; +} + +/** +* Interface describing function options. +*/ +interface Uint16Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'uint16'; +} + +/** +* Interface describing function options. +*/ +interface Uint8Options extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'uint8'; +} + +/** +* Interface describing function options. +*/ +interface Uint8COptions extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: 'uint8c'; +} + +/** +* Interface describing function options. +*/ +interface OptionsWithDType extends Options { + /** + * Underlying data type. + * + * ## Notes + * + * - This option overrides the input array's inferred data type. + */ + dtype: DataType; +} + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': float64' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': float32' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': complex128' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': complex64' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': int32' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': int16' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': int8' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': uint32' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': uint16' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': uint8' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ], { +* 'dtype': uint8c' +* }); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type (default: 'float64') +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ] ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param shape - array shape +* @param options - options +* @param options.dtype - underlying data type (default: 'float64') +* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @returns zero-filled array +* +* @example +* var arr = zeros( [ 2, 2 ] ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures + + +// EXPORTS // + +export = zeros; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2448409 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var m=e,p=r,l=t,j=s,f=n,h=i,g=d,y=o,b=a,u="row-major";var v=function(e){var r,t,s,n,i,d;if(t={},arguments.length>1){if(!m(r=arguments[1]))throw new TypeError(b("invalid argument. Options argument must be an object. Value: `%s`.",r));p(r,"dtype")?t.dtype=r.dtype:t.dtype="float64",p(r,"order")?t.order=r.order:t.order=u}else t.dtype="float64",t.order=u;if("number"==typeof e)d=[e];else{if(!l(e))throw new TypeError(b("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",e));d=e}if(d.length>0){if((n=g(d))!=n||n<0)throw new TypeError(b("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",e));i=j(d,t.order)}else n=1,i=[0];if(null===(s=h(t.dtype,n)))throw new TypeError(b("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",t.dtype));return new y(t.dtype,s,d,i,f(d,i),t.order)};export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c2a9892 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isPlainObject","require$$0","hasOwnProp","require$$1","isArrayLike","require$$2","shape2strides","require$$3","strides2offset","require$$4","buffer","require$$5","numel","require$$6","ndarray","require$$7","format","require$$8","ORDER","lib","shape","options","opts","buf","len","st","sh","arguments","length","TypeError","dtype","order"],"mappings":";;wxBAsBA,IAAIA,EAAgBC,EAChBC,EAAaC,EACbC,EAAcC,EACdC,EAAgBC,EAChBC,EAAiBC,EACjBC,EAASC,EACTC,EAAQC,EACRC,EAAUC,EACVC,EAASC,EAMTC,EAAQ,YAuFZ,IC5EAC,EDiBA,SAAgBC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAM5B,EADNqB,EAAUM,UAAW,IAEpB,MAAM,IAAIE,UAAWb,EAAQ,qEAAsEK,IAE/FnB,EAAYmB,EAAS,SACzBC,EAAKQ,MAAQT,EAAQS,MAErBR,EAAKQ,MA/CI,UAiDL5B,EAAYmB,EAAS,SACzBC,EAAKS,MAAQV,EAAQU,MAErBT,EAAKS,MAAQb,OAGdI,EAAKQ,MAvDK,UAwDVR,EAAKS,MAAQb,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,CAAA,IAAKhB,EAAagB,GAGxB,MAAM,IAAIS,UAAWb,EAAQ,0HAA2HI,IAFxJM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMZ,EAAOc,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIK,UAAWb,EAAQ,0HAA2HI,IAEzJK,EAAKnB,EAAeoB,EAAIJ,EAAKS,YAG7BP,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMb,EAAQY,EAAKQ,MAAON,IAEzB,MAAM,IAAIK,UAAWb,EAAQ,4EAA6E,QAASM,EAAKQ,QAEzH,OAAO,IAAIhB,EAASQ,EAAKQ,MAAOP,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,GAAMH,EAAKS"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..da573f0 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "@stdlib/ndarray-zeros", + "version": "0.0.0", + "description": "Create a zero-filled ndarray having a specified shape and data type.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-zeros.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "ndarray", + "matrix", + "fill", + "filled", + "zeros" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f521b45 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 30ffd8d876fd115d34f60bb93b6e4054b36bfb22 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:33:52 +0000 Subject: [PATCH 002/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a9d6e3b3aaeeb870396bc8af330214ff2c4c1f57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 13:25:34 +0000 Subject: [PATCH 003/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2448409..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var m=e,p=r,l=t,j=s,f=n,h=i,g=d,y=o,b=a,u="row-major";var v=function(e){var r,t,s,n,i,d;if(t={},arguments.length>1){if(!m(r=arguments[1]))throw new TypeError(b("invalid argument. Options argument must be an object. Value: `%s`.",r));p(r,"dtype")?t.dtype=r.dtype:t.dtype="float64",p(r,"order")?t.order=r.order:t.order=u}else t.dtype="float64",t.order=u;if("number"==typeof e)d=[e];else{if(!l(e))throw new TypeError(b("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",e));d=e}if(d.length>0){if((n=g(d))!=n||n<0)throw new TypeError(b("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",e));i=j(d,t.order)}else n=1,i=[0];if(null===(s=h(t.dtype,n)))throw new TypeError(b("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",t.dtype));return new y(t.dtype,s,d,i,f(d,i),t.order)};export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c2a9892..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isPlainObject","require$$0","hasOwnProp","require$$1","isArrayLike","require$$2","shape2strides","require$$3","strides2offset","require$$4","buffer","require$$5","numel","require$$6","ndarray","require$$7","format","require$$8","ORDER","lib","shape","options","opts","buf","len","st","sh","arguments","length","TypeError","dtype","order"],"mappings":";;wxBAsBA,IAAIA,EAAgBC,EAChBC,EAAaC,EACbC,EAAcC,EACdC,EAAgBC,EAChBC,EAAiBC,EACjBC,EAASC,EACTC,EAAQC,EACRC,EAAUC,EACVC,EAASC,EAMTC,EAAQ,YAuFZ,IC5EAC,EDiBA,SAAgBC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAM5B,EADNqB,EAAUM,UAAW,IAEpB,MAAM,IAAIE,UAAWb,EAAQ,qEAAsEK,IAE/FnB,EAAYmB,EAAS,SACzBC,EAAKQ,MAAQT,EAAQS,MAErBR,EAAKQ,MA/CI,UAiDL5B,EAAYmB,EAAS,SACzBC,EAAKS,MAAQV,EAAQU,MAErBT,EAAKS,MAAQb,OAGdI,EAAKQ,MAvDK,UAwDVR,EAAKS,MAAQb,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,CAAA,IAAKhB,EAAagB,GAGxB,MAAM,IAAIS,UAAWb,EAAQ,0HAA2HI,IAFxJM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMZ,EAAOc,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIK,UAAWb,EAAQ,0HAA2HI,IAEzJK,EAAKnB,EAAeoB,EAAIJ,EAAKS,YAG7BP,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMb,EAAQY,EAAKQ,MAAON,IAEzB,MAAM,IAAIK,UAAWb,EAAQ,4EAA6E,QAASM,EAAKQ,QAEzH,OAAO,IAAIhB,EAASQ,EAAKQ,MAAOP,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,GAAMH,EAAKS"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f521b45..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ba662681c866fbf673b8f72fd3a8545ae5cca643 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 13:26:19 +0000 Subject: [PATCH 004/114] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 39 +- benchmark/benchmark.js | 287 --- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 903 ------- 49 files changed, 2713 insertions(+), 5711 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 af467f9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:41:48.313Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.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/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - 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 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1eced8b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..93f417c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;iyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..e75ac4d --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 0ebf7eabd70b2e9ea4c8949a6446aef8211d666c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 16:49:37 +0000 Subject: [PATCH 005/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From d206369ccd031b4c10e8d51db1282a93a1a004bc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 16:49:56 +0000 Subject: [PATCH 006/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1eced8b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 93f417c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;iyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e75ac4d..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a6a944b36a20f8db9b5109f010f3293b7678a596 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 16:50:51 +0000 Subject: [PATCH 007/114] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 39 +- benchmark/benchmark.js | 287 --- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 903 ------- 48 files changed, 2713 insertions(+), 5676 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 d1026d0..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/zeros) 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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.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/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - 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 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +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 repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - 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 prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1eced8b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..93f417c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;iyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..156b490 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From f5b414cb655a764aa8ff8408cb16792b42ef5919 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:57:19 +0000 Subject: [PATCH 008/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 77c75b649fd6c4c905cda7454fd2dbca8314280f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 11:26:19 +0000 Subject: [PATCH 009/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1eced8b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 93f417c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;iyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 156b490..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a4a6ad481f1eaeb258f3407d9cd1f3f320354c94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 11:27:09 +0000 Subject: [PATCH 010/114] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 39 +- benchmark/benchmark.js | 287 --- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 903 ------- 49 files changed, 2713 insertions(+), 5750 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +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 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 3fde8f4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:43:58.186Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.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/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad25d1e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..b7d4075 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 773ae4ba634e85ab2811c8b71f56e1ab0e541319 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:49:29 +0000 Subject: [PATCH 011/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 47b7d63cd1a47c8be682fbe9a50b3a59e0161fe3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:24:01 +0000 Subject: [PATCH 012/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad25d1e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b7d4075..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 145172d0b5a0e089806cf01996039c79cbdb50bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:25:00 +0000 Subject: [PATCH 013/114] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 39 +- benchmark/benchmark.js | 287 --- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 903 ------- 49 files changed, 2713 insertions(+), 5766 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5a238d0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:44:08.872Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.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/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad25d1e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..1ba5955 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From f4b2d041828ab9969c4f9edd3fe46e15b4f450dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:18:24 +0000 Subject: [PATCH 014/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From fff76bbdd0fb4719765b8cc31cc037815822ce8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:15:00 +0000 Subject: [PATCH 015/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad25d1e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1ba5955..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 17a9b39954f3ca39bfa7e4784e80a456a0460fe9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:15:51 +0000 Subject: [PATCH 016/114] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 39 +- benchmark/benchmark.js | 287 --- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 903 ------- 49 files changed, 2713 insertions(+), 5766 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f70efac..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:11:47.297Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.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/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) 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 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=package_name::$name" - 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 "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - 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 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - 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 - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - 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 "::set-output name=alias::${alias}" - - # 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 + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ad25d1e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..f25784c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 26793eb327b7ff40a7e0e4c6e04d23bd617396b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:02:14 +0000 Subject: [PATCH 017/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 030d7e89e007576e82f4c3e9876ffc59c3815b63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:16:04 +0000 Subject: [PATCH 018/114] Remove files --- index.d.ts | 505 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3199 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ad25d1e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,GACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,OAGdI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,EAKN,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,YAG7BV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f25784c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 14b0650335fabff7d1068cdb1439934ae95013d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:16:57 +0000 Subject: [PATCH 019/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 903 ----- 49 files changed, 4068 insertions(+), 5766 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 85320e3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:57:11.591Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2d444ea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..89aa90f --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 03128b805f5e92e0a3c6de92040952f2292a6e76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:41:54 +0000 Subject: [PATCH 020/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 90f2b46..2429a1f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From d8b33136e5d1342c135a7d2f87f64139380d4418 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:52:26 +0000 Subject: [PATCH 021/114] Remove files --- index.d.ts | 505 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4554 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2d444ea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 89aa90f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e00d9e9f3b8b25ae21bd9a065ff643c0bcb47a9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:53:24 +0000 Subject: [PATCH 022/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 903 ----- 49 files changed, 4068 insertions(+), 5787 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4ea0dee..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:58:58.073Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2d444ea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2429a1f..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "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..9230e7c --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 16a16c54d37a28827eadf91ec6cfe66d351d0292 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:40:41 +0000 Subject: [PATCH 023/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 7febe48..7032e80 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 50c27904d8f9f3a7eb9569efc9bd95314684b36b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:46:31 +0000 Subject: [PATCH 024/114] Remove files --- index.d.ts | 505 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4554 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2d444ea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport isArrayLike from '@stdlib/assert-is-array-like' ;\nimport shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\nimport ndarray from '@stdlib/ndarray-ctor' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9230e7c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cdbbeb89d00e974bf3977c54adf4d308c790e4ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:47:30 +0000 Subject: [PATCH 025/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 903 ----- 49 files changed, 4068 insertions(+), 5792 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2c1b09d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:47:33.144Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +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: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; 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' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04d481d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc1065c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 7032e80..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "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..f7cda3e --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 35db5accd3997f12f2a4de81d664fb04c5927cef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:14:20 +0000 Subject: [PATCH 026/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 11ee93f..e004db8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -75,7 +75,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; @@ -96,14 +96,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, opts.order ); } else { @@ -113,7 +113,7 @@ function zeros( shape ) { } buf = buffer( opts.dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); } return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 1cd8629..59d41c7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a79405a16b5fa9afbd01ae03596aa9e00cf3f725 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:07:24 +0000 Subject: [PATCH 027/114] Remove files --- index.d.ts | 505 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4554 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04d481d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc1065c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f7cda3e..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 21ef6954ddd44c76ad72bc218cf0c156fb96bbcb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:08:20 +0000 Subject: [PATCH 028/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 124 - package.json | 77 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 903 --- 49 files changed, 6201 insertions(+), 5803 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2a8ecc5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:28:55.835Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +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 - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -175,7 +168,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -235,9 +228,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 55479af..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/zeros" -click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9be4c60..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e94ffb7..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2c220e9..f316c7d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ecf0dbf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc1065c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 e004db8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - } else { - opts.dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - } else { - opts.order = ORDER; - } - } else { - opts.dtype = DTYPE; - opts.order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, opts.order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( opts.dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', opts.dtype ) ); - } - return new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 59d41c7..7600c41 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-array-like": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/ndarray-ctor": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-ndarray-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "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..c69f9ca --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3d05f3b..0000000 --- a/test/test.js +++ /dev/null @@ -1,903 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); From 8a6741b7aedcf25009e1ccfa6874e7ab73758ea7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Mar 2023 22:26:47 +0000 Subject: [PATCH 029/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index f0d4b66..a0af411 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -81,7 +81,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -111,14 +111,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, order ); } else { @@ -128,7 +128,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 49cf353..211d729 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 01cc61fd08c4d28081c66014ce506338d4895714 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Mar 2023 22:27:15 +0000 Subject: [PATCH 030/114] Remove files --- index.d.ts | 505 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6687 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 f316c7d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,505 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ecf0dbf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p="row-major";function l(l){var a,j,h,f,y,b;if(j={},arguments.length>1){if(!e(a=arguments[1]))throw new TypeError(m("0N42h",a));r(a,"dtype")?j.dtype=a.dtype:j.dtype="float64",r(a,"order")?j.order=a.order:j.order=p}else j.dtype="float64",j.order=p;if("number"==typeof l)b=[l];else{if(!s(l))throw new TypeError(m("0N466",l));b=l}if(b.length>0){if((f=o(b))!=f||f<0)throw new TypeError(m("0N466",l));y=t(b,j.order)}else f=1,y=[0];if(null===(h=i(j.dtype,f)))throw new TypeError(m("0N45O","dtype",j.dtype));return new n(j.dtype,h,b,y,d(b,y),j.order)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc1065c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\topts.dtype = options.dtype;\n\t\t} else {\n\t\t\topts.dtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\topts.order = options.order;\n\t\t} else {\n\t\t\topts.order = ORDER;\n\t\t}\n\t} else {\n\t\topts.dtype = DTYPE;\n\t\topts.order = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, opts.order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( opts.dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', opts.dtype ) );\n\t}\n\treturn new ndarray( opts.dtype, buf, sh, st, strides2offset( sh, st ), opts.order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","dtype","order","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YA4BZ,SAASC,EAAOC,GACf,IAAIC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNR,EAAUM,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASV,IAElCW,EAAYX,EAAS,SACzBC,EAAKW,MAAQZ,EAAQY,MAErBX,EAAKW,MA/CI,UAiDLD,EAAYX,EAAS,SACzBC,EAAKY,MAAQb,EAAQa,MAErBZ,EAAKY,MAAQhB,CAEhB,MACEI,EAAKW,MAvDK,UAwDVX,EAAKY,MAAQhB,EAEd,GAAsB,iBAAVE,EACXM,EAAK,CAAEN,OACD,KAAKe,EAAaf,GAGxB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAFtCM,EAAKN,CAGL,CAED,GADQM,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMY,EAAOV,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAEvCK,EAAKY,EAAeX,EAAIJ,EAAKY,MAC/B,MAEEV,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMe,EAAQhB,EAAKW,MAAOT,IAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAAST,EAAKW,QAErD,OAAO,IAAIM,EAASjB,EAAKW,MAAOV,EAAKG,EAAID,EAAIe,EAAgBd,EAAID,GAAMH,EAAKY,MAC7E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c69f9ca..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fc551f2d3e546c2fceba9f4b9787e7979b5d7fda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Mar 2023 22:28:18 +0000 Subject: [PATCH 031/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 139 - package.json | 77 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1070 ---- 48 files changed, 6201 insertions(+), 6178 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -178,7 +171,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -238,9 +231,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index bff56c2..1cf0fac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..449548b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var l="row-major";function a(a){var p,j,h,f,b,y,c,g;if(f={},arguments.length>1){if(!e(p=arguments[1]))throw new TypeError(m("0N42h",p));j=r(p,"dtype")?p.dtype:"float64",h=r(p,"order")?p.order:l,r(p,"mode")&&(f.mode=p.mode),r(p,"submode")&&(f.submode=p.submode),r(p,"readonly")&&(f.readonly=p.readonly)}else j="float64",h=l;if("number"==typeof a)g=[a];else{if(!s(a))throw new TypeError(m("0N466",a));g=a}if(g.length>0){if((y=i(g))!=y||y<0)throw new TypeError(m("0N466",a));c=t(g,h)}else y=1,c=[0];if(null===(b=o(j,y)))throw new TypeError(m("0N45O","dtype",j));return new n(j,b,g,c,d(g,c),h,f)}export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..20a80f5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YAgCZ,SAASC,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAnDP,UAwDTC,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAtEU,UAuEVC,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 a0af411..0000000 --- a/lib/main.js +++ /dev/null @@ -1,139 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = 'float64'; -var ORDER = 'row-major'; - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 211d729..815eae4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,56 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-array-like": "^0.0.8", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/ndarray-base-buffer": "^0.0.6", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.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" - }, - "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..dc56863 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 12f5d5e2a0b6ee8d0abc87ee3ee9be6a9cfb64a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Apr 2023 01:26:22 +0000 Subject: [PATCH 032/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..96841f0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0N42h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0N466', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0N45O', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index f9388d9..6fa40bd 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.0.8", "@stdlib/ndarray-ctor": "^0.0.10", "@stdlib/ndarray-defaults": "github:stdlib-js/ndarray-defaults#main", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 6d588a0e3edca109bb7e752733ce4caffcc51196 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Apr 2023 01:26:55 +0000 Subject: [PATCH 033/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 1cf0fac..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 449548b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var l="row-major";function a(a){var p,j,h,f,b,y,c,g;if(f={},arguments.length>1){if(!e(p=arguments[1]))throw new TypeError(m("0N42h",p));j=r(p,"dtype")?p.dtype:"float64",h=r(p,"order")?p.order:l,r(p,"mode")&&(f.mode=p.mode),r(p,"submode")&&(f.submode=p.submode),r(p,"readonly")&&(f.readonly=p.readonly)}else j="float64",h=l;if("number"==typeof a)g=[a];else{if(!s(a))throw new TypeError(m("0N466",a));g=a}if(g.length>0){if((y=i(g))!=y||y<0)throw new TypeError(m("0N466",a));c=t(g,h)}else y=1,c=[0];if(null===(b=o(j,y)))throw new TypeError(m("0N45O","dtype",j));return new n(j,b,g,c,d(g,c),h,f)}export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 20a80f5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = 'float64';\nvar ORDER = 'row-major';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;wyBAmCA,IACIA,EAAQ,YAgCZ,SAASC,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAnDP,UAwDTC,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAtEU,UAuEVC,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dc56863..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 272fe9d3b85b0291f8e0cbe60981b5180dbc3dda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Apr 2023 01:27:54 +0000 Subject: [PATCH 034/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1070 ---- 48 files changed, 6201 insertions(+), 6180 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -178,7 +171,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -238,9 +231,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index bff56c2..1cf0fac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ee73949 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,h,f,b,y,g,c,v;if(b={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0N42h",j));h=s(j,"dtype")?j.dtype:p,f=s(j,"order")?j.order:a,s(j,"mode")&&(b.mode=j.mode),s(j,"submode")&&(b.submode=j.submode),s(j,"readonly")&&(b.readonly=j.readonly)}else h=p,f=a;if("number"==typeof m)v=[m];else{if(!r(m))throw new TypeError(l("0N466",m));v=m}if(v.length>0){if((g=n(v))!=g||g<0)throw new TypeError(l("0N466",m));c=t(v,f)}else g=1,c=[0];if(null===(y=i(h,g)))throw new TypeError(l("0N45O","dtype",h));return new o(h,y,v,c,d(v,c),f,b)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7c99ff6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;43BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 96841f0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0N42h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0N466', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0N466', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0N45O', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 6fa40bd..815eae4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-array-like": "^0.0.8", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/ndarray-base-buffer": "^0.0.6", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/ndarray-defaults": "github:stdlib-js/ndarray-defaults#main", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.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" - }, - "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..f110030 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 53753b4a45632ed1b89616f3a15d9b43de66108e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:21:53 +0000 Subject: [PATCH 035/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index bfbfc80..234aa91 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.0", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From bd83f3c12487f11e67394417a913f10183e862ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:46:20 +0000 Subject: [PATCH 036/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 1cf0fac..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ee73949..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,h,f,b,y,g,c,v;if(b={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0N42h",j));h=s(j,"dtype")?j.dtype:p,f=s(j,"order")?j.order:a,s(j,"mode")&&(b.mode=j.mode),s(j,"submode")&&(b.submode=j.submode),s(j,"readonly")&&(b.readonly=j.readonly)}else h=p,f=a;if("number"==typeof m)v=[m];else{if(!r(m))throw new TypeError(l("0N466",m));v=m}if(v.length>0){if((g=n(v))!=g||g<0)throw new TypeError(l("0N466",m));c=t(v,f)}else g=1,c=[0];if(null===(y=i(h,g)))throw new TypeError(l("0N45O","dtype",h));return new o(h,y,v,c,d(v,c),f,b)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7c99ff6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0N42h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0N466', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0N466', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0N45O', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;43BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f110030..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From deb6cfeb2d4c630b66c38496b56c563e05a7b7a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:47:24 +0000 Subject: [PATCH 037/114] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1070 ---- 52 files changed, 6201 insertions(+), 6215 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index ee4b1ac..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3d3cde1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -249,9 +242,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a5882dd..df73869 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f0b5c48 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 234aa91..d30ef44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-array-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/ndarray-base-buffer": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^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..79b7c6e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From a3397cd7c4732c1662368fd4c8dd42508f180673 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:59:46 +0000 Subject: [PATCH 038/114] 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 b6b2e42..d59a51b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@v0.1.0-esm/index.mjs'; ``` #### zeros( shape\[, options] ) @@ -133,7 +133,7 @@ var dt = arr.dtype; - - - - From 980e1b248276db0ac41827fe9dbc61750b2165d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:32:36 +0000 Subject: [PATCH 042/114] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1070 ---- test/test.js | 1070 ---- 54 files changed, 6201 insertions(+), 7344 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9cccc66..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:33:23.744Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -249,9 +242,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a5882dd..df73869 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8eced2c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index cf04414..d30ef44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-array-like": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^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..534d245 --- /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 1d5c09a..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 4baa61bae5fc64e5cf5023c68365376bc4bdda2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:18:13 +0000 Subject: [PATCH 043/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index cab394f..5fc63e3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From ac86238a711261086d76b80eb01349232e5b68aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:36:23 +0000 Subject: [PATCH 044/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 df73869..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8eced2c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 534d245..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 82919ec0178c8f348473b23a21936b69a3a638f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:37:39 +0000 Subject: [PATCH 045/114] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1070 ---- test/test.js | 1070 ---- 53 files changed, 6201 insertions(+), 7343 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -249,9 +242,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a5882dd..df73869 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 5fc63e3..d30ef44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex64": "^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..d9bd122 --- /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 1d5c09a..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 03f71b15e67f493685bd430f9ceefd3885b65085 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 18:01:20 +0000 Subject: [PATCH 046/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index cb63d15..d8c7d16 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 0db3a849503e710188775eaf0f099f73a791d1e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:43:33 +0000 Subject: [PATCH 047/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 df73869..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d9bd122..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9cebabac5a78e68c4dc2e770537aa6bbef4556b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:44:37 +0000 Subject: [PATCH 048/114] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 54 files changed, 6201 insertions(+), 6315 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index eca1fe3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:54:32.538Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -249,9 +242,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index a5882dd..df73869 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d8c7d16..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..812df00 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 3970c7d13f5f5d4e6c5183008b3ac1600f58a589 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Nov 2023 08:31:05 +0000 Subject: [PATCH 049/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index cb63d15..d8c7d16 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From bc0bac0c0dbac9398cbd7e2187bd264fe30de785 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Nov 2023 08:35:36 +0000 Subject: [PATCH 050/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 df73869..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 812df00..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2599a1efecafcdab6dd2e37aecc7259c4ebad39a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Nov 2023 08:36:32 +0000 Subject: [PATCH 051/114] 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 | 39 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 53 files changed, 6201 insertions(+), 6314 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -249,9 +242,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d8c7d16..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c6920f7 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 9fc315ac7bd23c787f8ecc8c9aa3a664eb7f0ad6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:31:39 +0000 Subject: [PATCH 052/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 460f551..c4f3541 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 63119c494f63be6df1f47aacbadc1f51e0fc24a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:21:39 +0000 Subject: [PATCH 053/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c6920f7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e9b0d7c7f7111b279ce2b8e69b9ff163d25951a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:22:51 +0000 Subject: [PATCH 054/114] 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 | 43 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 53 files changed, 6203 insertions(+), 6316 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -196,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -256,15 +249,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ee4d5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index c4f3541..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..71d1f32 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 13fc4b73736c0d27af121fa5d1df4a140607c9f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:30:37 +0000 Subject: [PATCH 055/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index f92cd54..bdf9af5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 2c7ff5fd51aa65d8fff5ef493337bfaeb726d816 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:35:17 +0000 Subject: [PATCH 056/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 71d1f32..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b5ccaa783b2e5827e803674258b2194a3aef9379 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:36:07 +0000 Subject: [PATCH 057/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 53 files changed, 6203 insertions(+), 6315 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -196,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -256,15 +249,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bdf9af5..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c30c0f9 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 409f485e5898c0f359c297b8225fdc097468cca2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:10:54 +0000 Subject: [PATCH 058/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..b805930 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s,Kf', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index f92cd54..bdf9af5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From c291ab1aaf339bcb346d05ae6c20272fea594f9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:26:17 +0000 Subject: [PATCH 059/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c30c0f9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8bef4a71b4fd233b95639c2bae8e0c8ec828bdab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:27:01 +0000 Subject: [PATCH 060/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 54 files changed, 6203 insertions(+), 6316 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7681368..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:59:48.490Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 ed25e71..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: '5 17 * * 0' - - # 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 + + ```
@@ -196,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -256,15 +249,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 524a856..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index d5ee3e8..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index f97f124..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index e492527..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4f6d600..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5292f49..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 4ada183..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 155892a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 5511881..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index 5018191..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 66f506f..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d50badb..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index e5a1dc1..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a413502 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d74e796 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 b805930..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s,Kf', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bdf9af5..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..306aa06 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From be92243259ad50a7396df15033b108b6b3ba340b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:30:57 +0000 Subject: [PATCH 061/114] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0b31ad..ea72b1f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 4d67f25b989367c488183c8848c8837a7ed06e54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:05:45 +0000 Subject: [PATCH 062/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a413502..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V,FD",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s,Kf",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s,Kf",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJ5A,Bf,Kc","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d74e796..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s,Kf', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJ5A,Bf,Kc', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;o7BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,WAAYZ,IAGzCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,WAAYb,IAFzCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,WAAYb,IAE1CO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,cAAe,QAASX,IAEtD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 306aa06..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5a6619f1f1cd7f10e56207f6cfb0cdc45db3c989 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:06:05 +0000 Subject: [PATCH 063/114] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 55 files changed, 6203 insertions(+), 6322 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d8c9f08..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:29:55.329Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 974234f..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: '5 17 * * 0' - - # 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 + + ```
@@ -196,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -256,15 +249,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6eae28e..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d04074 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var l=a.get("dtypes.default"),p=a.get("order");function j(a){var j,g,h,f,v,b,u,y;if(f={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",j));g=t(j,"dtype")?j.dtype:l,h=t(j,"order")?j.order:p,t(j,"mode")&&(f.mode=j.mode),t(j,"submode")&&(f.submode=j.submode),t(j,"readonly")&&(f.readonly=j.readonly)}else g=l,h=p;if("number"==typeof a)y=[a];else{if(!r(a))throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));y=a}if(y.length>0){if((b=d(y))!=b||b<0)throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));u=s(y,h)}else b=1,u=[0];if(null===(v=i(g,b)))throw new TypeError(m("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",g));return new o(g,v,y,u,n(y,u),h,f)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a280e35 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;26BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,qEAAsEZ,IAGnGC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,0HAA2Hb,IAFxJQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,0HAA2Hb,IAEzJO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,4EAA6E,QAASX,IAEpH,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 feaabb6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ea72b1f..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.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.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..779180f --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From ff662d39a2aee6c3f2429a1cb55c46e7f5cd6d88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:08:26 +0000 Subject: [PATCH 064/114] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0b31ad..ea72b1f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 173b317232ba48ee0679046c9d28a7f6638f36fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:28:07 +0000 Subject: [PATCH 065/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d04074..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var l=a.get("dtypes.default"),p=a.get("order");function j(a){var j,g,h,f,v,b,u,y;if(f={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",j));g=t(j,"dtype")?j.dtype:l,h=t(j,"order")?j.order:p,t(j,"mode")&&(f.mode=j.mode),t(j,"submode")&&(f.submode=j.submode),t(j,"readonly")&&(f.readonly=j.readonly)}else g=l,h=p;if("number"==typeof a)y=[a];else{if(!r(a))throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));y=a}if(y.length>0){if((b=d(y))!=b||b<0)throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));u=s(y,h)}else b=1,u=[0];if(null===(v=i(g,b)))throw new TypeError(m("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",g));return new o(g,v,y,u,n(y,u),h,f)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a280e35..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;26BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,qEAAsEZ,IAGnGC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,0HAA2Hb,IAFxJQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,0HAA2Hb,IAEzJO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,4EAA6E,QAASX,IAEpH,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 779180f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9ff4ee44ed070ab7a50cc0ea0a19757010358a5c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:28:31 +0000 Subject: [PATCH 066/114] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 55 files changed, 6203 insertions(+), 6327 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c3b9f14..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:24:25.695Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 974234f..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0d04074 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var l=a.get("dtypes.default"),p=a.get("order");function j(a){var j,g,h,f,v,b,u,y;if(f={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",j));g=t(j,"dtype")?j.dtype:l,h=t(j,"order")?j.order:p,t(j,"mode")&&(f.mode=j.mode),t(j,"submode")&&(f.submode=j.submode),t(j,"readonly")&&(f.readonly=j.readonly)}else g=l,h=p;if("number"==typeof a)y=[a];else{if(!r(a))throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));y=a}if(y.length>0){if((b=d(y))!=b||b<0)throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));u=s(y,h)}else b=1,u=[0];if(null===(v=i(g,b)))throw new TypeError(m("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",g));return new o(g,v,y,u,n(y,u),h,f)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a280e35 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;26BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,qEAAsEZ,IAGnGC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,0HAA2Hb,IAFxJQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,0HAA2Hb,IAEzJO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,4EAA6E,QAASX,IAEpH,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 feaabb6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ea72b1f..5b4d383 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-defaults": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.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.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..9840f18 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 424b83c0e5d4c4519df623dbd77306c338d983e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:17:23 +0000 Subject: [PATCH 067/114] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 415579b..90c99fb 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.0", "@stdlib/ndarray-ctor": "^0.2.0", "@stdlib/ndarray-defaults": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From de497206b4e41f736cb5990f5e4e9bb82ea722ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:43:44 +0000 Subject: [PATCH 068/114] Remove files --- index.d.ts | 559 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6741 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d04074..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var l=a.get("dtypes.default"),p=a.get("order");function j(a){var j,g,h,f,v,b,u,y;if(f={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",j));g=t(j,"dtype")?j.dtype:l,h=t(j,"order")?j.order:p,t(j,"mode")&&(f.mode=j.mode),t(j,"submode")&&(f.submode=j.submode),t(j,"readonly")&&(f.readonly=j.readonly)}else g=l,h=p;if("number"==typeof a)y=[a];else{if(!r(a))throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));y=a}if(y.length>0){if((b=d(y))!=b||b<0)throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));u=s(y,h)}else b=1,u=[0];if(null===(v=i(g,b)))throw new TypeError(m("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",g));return new o(g,v,y,u,n(y,u),h,f)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a280e35..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;26BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,qEAAsEZ,IAGnGC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,0HAA2Hb,IAFxJQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,0HAA2Hb,IAEzJO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,4EAA6E,QAASX,IAEpH,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9840f18..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 937706dacda8a4ccc076dcebea59574872d7f7ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:44:14 +0000 Subject: [PATCH 069/114] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 - benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 78 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 54 files changed, 6203 insertions(+), 6330 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 2a3f8b5..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7460939 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var l=a.get("dtypes.default"),p=a.get("order");function j(a){var j,g,h,f,v,b,u,y;if(f={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",j));g=t(j,"dtype")?j.dtype:l,h=t(j,"order")?j.order:p,t(j,"mode")&&(f.mode=j.mode),t(j,"submode")&&(f.submode=j.submode),t(j,"readonly")&&(f.readonly=j.readonly)}else g=l,h=p;if("number"==typeof a)y=[a];else{if(!r(a))throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));y=a}if(y.length>0){if((b=d(y))!=b||b<0)throw new TypeError(m("invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.",a));u=s(y,h)}else b=1,u=[0];if(null===(v=i(g,b)))throw new TypeError(m("invalid option. `%s` option must be a recognized data type. Option: `%s`.","dtype",g));return new o(g,v,y,u,n(y,u),h,f)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a280e35 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;26BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,qEAAsEZ,IAGnGC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,0HAA2Hb,IAFxJQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,0HAA2Hb,IAEzJO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,4EAA6E,QAASX,IAEpH,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 feaabb6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 90c99fb..b3aaec3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,57 +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": "^0.2.0", - "@stdlib/assert-is-plain-object": "^0.2.0", - "@stdlib/ndarray-base-buffer": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/ndarray-ctor": "^0.2.0", - "@stdlib/ndarray-defaults": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-int16": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-int8": "^0.2.0", - "@stdlib/array-uint16": "^0.2.0", - "@stdlib/array-uint32": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-instance-of": "^0.2.0", - "@stdlib/assert-is-ndarray-like": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/ndarray-dtypes": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex64": "^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..9403af9 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From bdfec8bd3a0f0331003d7550e47ee86471cd5338 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:35:49 +0000 Subject: [PATCH 070/114] 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 1ae2c04..34a4689 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@v0.2.0-esm/index.mjs'; ``` #### zeros( shape\[, options] ) @@ -133,7 +133,7 @@ var dt = arr.dtype; - - - - From 3b97e3a56626895f2f11de2d6921fc1e284fe60f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:18:32 +0000 Subject: [PATCH 074/114] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 54 files changed, 4868 insertions(+), 6325 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fbcaae0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index a663883..8af5cb7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..395d313 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From a15ab71c68dffa239ff5c22f213a4171aff53d16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:56:39 +0000 Subject: [PATCH 075/114] 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 c43d52c..c3b4bf9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@v0.2.1-esm/index.mjs'; ``` #### zeros( shape\[, options] ) @@ -133,7 +133,7 @@ var dt = arr.dtype; - - - - From 87e6df12d48ab59c838d9a3382110d7d0bf8f941 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:06:45 +0000 Subject: [PATCH 079/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 55 files changed, 4868 insertions(+), 6327 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5f29040..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:03:39.736Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cfeac50 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bab4427..8af5cb7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ac79fe4 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 4cf71e835a50b568a3c68de80596046120f02a80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:40:46 +0000 Subject: [PATCH 080/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 164f630..bab4427 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.1", "@stdlib/ndarray-ctor": "^0.2.1", "@stdlib/ndarray-defaults": "^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 f6148159072846da51faadbd3ae381c98ff38256 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:09:13 +0000 Subject: [PATCH 081/114] Remove files --- index.d.ts | 559 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5406 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cfeac50..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ac79fe4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1717e758d797e2a5fd1b5439c11b4b87ccd84b9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:09:28 +0000 Subject: [PATCH 082/114] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 55 files changed, 4868 insertions(+), 6330 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bfb762e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:19:42.922Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cfeac50 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bab4427..8af5cb7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ac79fe4 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 84d8d821e07310ac76835d16edfe8d35ac0f6488 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:54:21 +0000 Subject: [PATCH 083/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 164f630..bab4427 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.1", "@stdlib/ndarray-ctor": "^0.2.1", "@stdlib/ndarray-defaults": "^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 98f9ab7d16f6649821a506c6e4e883e473f22c5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:17:39 +0000 Subject: [PATCH 084/114] Remove files --- index.d.ts | 559 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5406 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cfeac50..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ac79fe4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e95e3a49fd1714439155a5d5826067287863af61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:18:02 +0000 Subject: [PATCH 085/114] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 62 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 54 files changed, 4868 insertions(+), 6331 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 99ed33d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,62 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Default: 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7123d6e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 75397d4..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 38e2261..d58f82f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cfeac50 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bab4427..8af5cb7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ac79fe4 --- /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 f5ad401..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 2ea4ccaa8267f475b0c47cee160ab779926a0f70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:33:29 +0000 Subject: [PATCH 086/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 164f630..bab4427 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.1", "@stdlib/ndarray-ctor": "^0.2.1", "@stdlib/ndarray-defaults": "^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 3d1d9bd87eb9575dcef28f4face604ca39685388 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:36:41 +0000 Subject: [PATCH 087/114] Remove files --- index.d.ts | 559 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5406 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 d58f82f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,559 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cfeac50..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ac79fe4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 79b28b2d3da95d0e444465ef2a83fe14777c577e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:36:56 +0000 Subject: [PATCH 088/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 127 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 54 files changed, 4868 insertions(+), 6465 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cfeac50 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index bab4427..8af5cb7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array-like": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ac79fe4 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From adac1f1b867d04335fea739439a8a99f319586c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:26:48 +0000 Subject: [PATCH 089/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 0662cad..d3c8ee7 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.1", "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From f25586afca07228accae27b64bd65115b1102a23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:46:50 +0000 Subject: [PATCH 090/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cfeac50..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ac79fe4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From da677133273498ad0ff3c4c246333ff1d48ff517 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:47:07 +0000 Subject: [PATCH 091/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 190 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 54 files changed, 4868 insertions(+), 6530 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7375f84 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d3c8ee7..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3af2414 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From d8e29d4412ee11ef9dc2634dea605174495ef651 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:52:53 +0000 Subject: [PATCH 092/114] Update README.md for ESM bundle v0.3.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16a2bee..d4cbc56 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@v0.3.0-esm/index.mjs'; ``` #### zeros( shape\[, options] ) @@ -133,7 +133,7 @@ var dt = arr.dtype; - - - - From bf0da28b57c4384154a8fd900676d6c7944766ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:27:42 +0000 Subject: [PATCH 096/114] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 88 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ----- 55 files changed, 4868 insertions(+), 6429 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 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 c3aa2e2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:13:35.073Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..14a903e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2bbb81a..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f6222c9 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From fd9a521802d0224bf0ddd3655401cf86e453e437 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 00:53:40 +0000 Subject: [PATCH 097/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 3a9ccbc..ed92258 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 083941739f5c7c1c11bf716423f13c26925a911c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:16:23 +0000 Subject: [PATCH 098/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 14a903e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f6222c9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 94c3d5087bb0cb3c52cdabdf16d2b5ac33bb1834 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:16:49 +0000 Subject: [PATCH 099/114] 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 | 189 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 56 files changed, 4868 insertions(+), 6634 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c2a5cc7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-03T00:46:22.265Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d1026d0..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c2bee63 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ed92258..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f6222c9 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 419cca576cb97620940972a31fd648a7f301fe7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:18:40 +0000 Subject: [PATCH 100/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index feaabb6..7cd99a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -82,7 +82,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -112,14 +112,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -129,7 +129,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 3a9ccbc..ed92258 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 2ae280dde7186500a7a9982ebacb47ddb31dd8d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:43:57 +0000 Subject: [PATCH 101/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c2bee63..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f6222c9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9f967c0d206967cae45a074fe159a2e526c7044a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:44:21 +0000 Subject: [PATCH 102/114] 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 | 189 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 140 - package.json | 79 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 56 files changed, 4868 insertions(+), 6638 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b517e79..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:17:32.700Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7df4cd5..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 50cf43d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(x,y){ -var q=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/assert-is-array-like/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),h=require('@stdlib/ndarray-base-strides2offset/dist'),E=require('@stdlib/ndarray-base-buffer/dist'),O=require('@stdlib/ndarray-base-numel/dist'),T=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),f=g.get("dtypes.default"),m=g.get("order");function P(r){var e,a,n,l,o,v,i,u,t;if(o={},arguments.length>1){if(e=arguments[1],!q(e))throw new TypeError(d('0kJ2V',e));s(e,"dtype")?a=e.dtype:a=f,s(e,"order")?n=e.order:n=m,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else a=f,n=m;if(typeof r=="number")t=[r];else if(w(r))t=r;else throw new TypeError(d('0kJ5s',r));if(l=t.length,l>0){if(i=O(t),i!==i||i<0)throw new TypeError(d('0kJ5s',r));u=c(t,n)}else i=1,u=[0];if(v=E(a,i),v===null)throw new TypeError(d('0kJBf',"dtype",a));return new T(a,v,t,u,h(t,u),n,o)}y.exports=P -});var V=p();module.exports=V; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index b035f9f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\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,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAK,OAAOE,GAAU,SACrBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAnB,EAAO,QAAUa,ICjGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c2bee63 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b6b1b68 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 7cd99a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,140 +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. -*/ - -'use strict'; - -// MODULES // - -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( typeof shape === 'number' ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ed92258..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f6222c9 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From fc6b50212ee3a0bcec1f4515c12029fcd340cbf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:08:57 +0000 Subject: [PATCH 103/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0ae451e..8ab5a50 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -83,7 +83,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -113,14 +113,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -130,7 +130,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 12beab7..ae8eaff 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 beeb956313d03b2160d7bfa6e75c091e59b05a22 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:11:24 +0000 Subject: [PATCH 104/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c2bee63..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=m.get("dtypes.default"),a=m.get("order");function j(m){var j,f,h,v,b,y,g,c;if(v={},arguments.length>1){if(!e(j=arguments[1]))throw new TypeError(l("0kJ2V",j));f=s(j,"dtype")?j.dtype:p,h=s(j,"order")?j.order:a,s(j,"mode")&&(v.mode=j.mode),s(j,"submode")&&(v.submode=j.submode),s(j,"readonly")&&(v.readonly=j.readonly)}else f=p,h=a;if("number"==typeof m)c=[m];else{if(!r(m))throw new TypeError(l("0kJ5s",m));c=m}if(c.length>0){if((y=n(c))!=y||y<0)throw new TypeError(l("0kJ5s",m));g=t(c,h)}else y=1,g=[0];if(null===(b=i(f,y)))throw new TypeError(l("0kJBf","dtype",f));return new o(f,b,c,g,d(c,g),h,v)}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b6b1b68..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( typeof shape === 'number' ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;27BAoCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAsB,iBAAVE,EACXQ,EAAK,CAAER,OACD,KAAKkB,EAAalB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMa,EAAOX,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKa,EAAeZ,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMgB,EAAQnB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIoB,EAASpB,EAAOG,EAAKG,EAAID,EAAIgB,EAAgBf,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f6222c9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf21b4b3d27cbfb01a6dfc2d925b4049bcc10642 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:12:04 +0000 Subject: [PATCH 105/114] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 223 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 141 - package.json | 80 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 55 files changed, 4868 insertions(+), 6673 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7df4cd5..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 613af24..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(z,y){ -var q=require('@stdlib/assert-is-number/dist').isPrimitive,w=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/assert-is-array-like/dist'),h=require('@stdlib/ndarray-base-shape2strides/dist'),E=require('@stdlib/ndarray-base-strides2offset/dist'),O=require('@stdlib/ndarray-base-buffer/dist'),T=require('@stdlib/ndarray-base-numel/dist'),P=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),m=g.get("dtypes.default"),f=g.get("order");function V(r){var e,t,n,l,o,d,a,u,i;if(o={},arguments.length>1){if(e=arguments[1],!w(e))throw new TypeError(v('0kJ2V',e));s(e,"dtype")?t=e.dtype:t=m,s(e,"order")?n=e.order:n=f,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else t=m,n=f;if(q(r))i=[r];else if(c(r))i=r;else throw new TypeError(v('0kJ5s',r));if(l=i.length,l>0){if(a=T(i),a!==a||a<0)throw new TypeError(v('0kJ5s',r));u=h(i,n)}else a=1,u=[0];if(d=O(t,a),d===null)throw new TypeError(v('0kJBf',"dtype",t));return new P(t,d,i,u,E(i,u),n,o)}y.exports=V -});var j=p();module.exports=j; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8d629f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAKZ,EAAUc,CAAM,EACpBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKApB,EAAO,QAAUc,IClGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e9d57f3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..41f41da --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 8ab5a50..0000000 --- a/lib/main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( isNumber( shape ) ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ae8eaff..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,59 +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": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..010b937 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From d925a475ccb9b85404989adea0508d026821fdf6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:41:28 +0000 Subject: [PATCH 106/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0ae451e..8ab5a50 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -83,7 +83,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -113,14 +113,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -130,7 +130,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 12beab7..ae8eaff 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 11ef29d423f3f4994f17b1bdbf68ed305597c436 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:45:34 +0000 Subject: [PATCH 107/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e9d57f3..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{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 41f41da..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 010b937..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 54655a1a5d6b2cb70dfde4a626cc365c0aad3f3e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:45:58 +0000 Subject: [PATCH 108/114] 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 | 223 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 141 - package.json | 80 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 56 files changed, 4868 insertions(+), 6674 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1a7efda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-12T00:39:45.718Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7df4cd5..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 613af24..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(z,y){ -var q=require('@stdlib/assert-is-number/dist').isPrimitive,w=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/assert-is-array-like/dist'),h=require('@stdlib/ndarray-base-shape2strides/dist'),E=require('@stdlib/ndarray-base-strides2offset/dist'),O=require('@stdlib/ndarray-base-buffer/dist'),T=require('@stdlib/ndarray-base-numel/dist'),P=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),m=g.get("dtypes.default"),f=g.get("order");function V(r){var e,t,n,l,o,d,a,u,i;if(o={},arguments.length>1){if(e=arguments[1],!w(e))throw new TypeError(v('0kJ2V',e));s(e,"dtype")?t=e.dtype:t=m,s(e,"order")?n=e.order:n=f,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else t=m,n=f;if(q(r))i=[r];else if(c(r))i=r;else throw new TypeError(v('0kJ5s',r));if(l=i.length,l>0){if(a=T(i),a!==a||a<0)throw new TypeError(v('0kJ5s',r));u=h(i,n)}else a=1,u=[0];if(d=O(t,a),d===null)throw new TypeError(v('0kJBf',"dtype",t));return new P(t,d,i,u,E(i,u),n,o)}y.exports=V -});var j=p();module.exports=j; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8d629f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAKZ,EAAUc,CAAM,EACpBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKApB,EAAO,QAAUc,IClGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e9d57f3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..41f41da --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 8ab5a50..0000000 --- a/lib/main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( isNumber( shape ) ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ae8eaff..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,59 +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": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..010b937 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 20e5a7f74cd6d7d2d95abe021b6717d7aafb804b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:42:41 +0000 Subject: [PATCH 109/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0ae451e..8ab5a50 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -83,7 +83,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -113,14 +113,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -130,7 +130,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 12beab7..ae8eaff 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 e5e12a651bf30f33f395b52560c21d873ddcf509 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:46:32 +0000 Subject: [PATCH 110/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e9d57f3..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{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 41f41da..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 010b937..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 04f9423586e6bd22129b98be6688107d471aed87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:47:00 +0000 Subject: [PATCH 111/114] 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 | 223 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 141 - package.json | 80 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 56 files changed, 4868 insertions(+), 6674 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d79c069..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T00:42:14.395Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7df4cd5..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 613af24..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(z,y){ -var q=require('@stdlib/assert-is-number/dist').isPrimitive,w=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/assert-is-array-like/dist'),h=require('@stdlib/ndarray-base-shape2strides/dist'),E=require('@stdlib/ndarray-base-strides2offset/dist'),O=require('@stdlib/ndarray-base-buffer/dist'),T=require('@stdlib/ndarray-base-numel/dist'),P=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),m=g.get("dtypes.default"),f=g.get("order");function V(r){var e,t,n,l,o,d,a,u,i;if(o={},arguments.length>1){if(e=arguments[1],!w(e))throw new TypeError(v('0kJ2V',e));s(e,"dtype")?t=e.dtype:t=m,s(e,"order")?n=e.order:n=f,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else t=m,n=f;if(q(r))i=[r];else if(c(r))i=r;else throw new TypeError(v('0kJ5s',r));if(l=i.length,l>0){if(a=T(i),a!==a||a<0)throw new TypeError(v('0kJ5s',r));u=h(i,n)}else a=1,u=[0];if(d=O(t,a),d===null)throw new TypeError(v('0kJBf',"dtype",t));return new P(t,d,i,u,E(i,u),n,o)}y.exports=V -});var j=p();module.exports=j; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8d629f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAKZ,EAAUc,CAAM,EACpBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKApB,EAAO,QAAUc,IClGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e9d57f3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..41f41da --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 8ab5a50..0000000 --- a/lib/main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( isNumber( shape ) ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ae8eaff..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,59 +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": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..010b937 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 45befff74925a28056d9bce1ab7def906a277846 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:45:36 +0000 Subject: [PATCH 112/114] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0ae451e..8ab5a50 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var buffer = require( '@stdlib/ndarray-base-buffer' ); var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -83,7 +83,7 @@ function zeros( shape ) { if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0kJ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -113,14 +113,14 @@ function zeros( shape ) { } else if ( isArrayLike( shape ) ) { sh = shape; } else { - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } ndims = sh.length; if ( ndims > 0 ) { len = numel( sh ); if ( len !== len || len < 0 ) { // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( '0kJ5s', shape ) ); } st = shape2strides( sh, order ); } else { @@ -130,7 +130,7 @@ function zeros( shape ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) ); + throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); } return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 12beab7..ae8eaff 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@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 b60ecdbbd3e2db4ebd837634183612ec612402be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 02:32:34 +0000 Subject: [PATCH 113/114] Remove files --- index.d.ts | 613 ------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5460 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 0fa38fa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,613 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: NumericAndGenericDataType; -} - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options: Float64Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( shape: Shape | number, options: Float32Options ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex128' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( shape: Shape | number, options: Complex128Options ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': complex64' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( shape: Shape | number, options: Complex64Options ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( shape: Shape | number, options: Int32Options ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( shape: Shape | number, options: Int16Options ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': int8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( shape: Shape | number, options: Int8Options ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( shape: Shape | number, options: Uint32Options ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint16' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( shape: Shape | number, options: Uint16Options ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( shape: Shape | number, options: Uint8Options ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': uint8c' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( shape: Shape | number, options: Uint8COptions ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ], { -* 'dtype': generic' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( shape: Shape | number, options: GenericOptions ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: Options ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param shape - array shape -* @param options - options -* @param options.dtype - underlying data type (default: 'float64') -* @param options.order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major') -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param options.readonly - boolean indicating whether an array should be read-only -* @returns zero-filled array -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( shape: Shape | number, options?: OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e9d57f3..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{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 41f41da..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 010b937..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From af3f4fb36ea9430aa5cc73a1e587e3697eda7d0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 02:33:05 +0000 Subject: [PATCH 114/114] 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 | 223 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 287 -- benchmark/benchmark.size.complex128.js | 98 - benchmark/benchmark.size.complex64.js | 98 - benchmark/benchmark.size.float32.js | 98 - benchmark/benchmark.size.float64.js | 98 - benchmark/benchmark.size.generic.js | 98 - benchmark/benchmark.size.int16.js | 98 - benchmark/benchmark.size.int32.js | 98 - benchmark/benchmark.size.int8.js | 98 - benchmark/benchmark.size.uint16.js | 98 - benchmark/benchmark.size.uint32.js | 98 - benchmark/benchmark.size.uint8.js | 98 - benchmark/benchmark.size.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 63 - docs/types/test.ts | 132 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 48 - lib/main.js | 141 - package.json | 80 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1070 ---- 56 files changed, 4868 insertions(+), 6674 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d42b835..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T01:27:18.322Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7df4cd5..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/zeros) 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 a1b8233..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/zeros) 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 f504e98..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: '5 17 * * 0' - - # 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 + + ```
@@ -198,7 +189,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -261,15 +252,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 745a353..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,287 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ] ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'float32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex128' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'complex64' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint32' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint16' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'int8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'uint8c' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ 0 ], { - 'dtype': 'generic' - }); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 620c9c3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index a5dd861..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 7a75db1..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 4dec079..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 583cb82..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index a9d3ae9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 3259c7a..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index e984401..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'int8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index cd43cbd..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint16' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 114d1e0..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index d8f873b..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 6959e7a..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var arr; - var i; - - opts = { - 'dtype': 'uint8c' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( [ len ], opts ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index fdda80f..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/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/zeros -[production-url]: https://github.com/stdlib-js/ndarray-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-zeros/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 9248683..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import zeros from '../docs/types/index'; -export = zeros; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 613af24..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var b=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=b(function(z,y){ -var q=require('@stdlib/assert-is-number/dist').isPrimitive,w=require('@stdlib/assert-is-plain-object/dist'),s=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/assert-is-array-like/dist'),h=require('@stdlib/ndarray-base-shape2strides/dist'),E=require('@stdlib/ndarray-base-strides2offset/dist'),O=require('@stdlib/ndarray-base-buffer/dist'),T=require('@stdlib/ndarray-base-numel/dist'),P=require('@stdlib/ndarray-ctor/dist'),g=require('@stdlib/ndarray-defaults/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist'),m=g.get("dtypes.default"),f=g.get("order");function V(r){var e,t,n,l,o,d,a,u,i;if(o={},arguments.length>1){if(e=arguments[1],!w(e))throw new TypeError(v('0kJ2V',e));s(e,"dtype")?t=e.dtype:t=m,s(e,"order")?n=e.order:n=f,s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode),s(e,"readonly")&&(o.readonly=e.readonly)}else t=m,n=f;if(q(r))i=[r];else if(c(r))i=r;else throw new TypeError(v('0kJ5s',r));if(l=i.length,l>0){if(a=T(i),a!==a||a<0)throw new TypeError(v('0kJ5s',r));u=h(i,n)}else a=1,u=[0];if(d=O(t,a),d===null)throw new TypeError(v('0kJBf',"dtype",t));return new P(t,d,i,u,E(i,u),n,o)}y.exports=V -});var j=p();module.exports=j; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 8d629f7..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isArrayLike = require( '@stdlib/assert-is-array-like' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a recognized data type. Option: `%s`.', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled ndarray having a specified shape and data type.\n*\n* @module @stdlib/ndarray-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var arr = zeros( [ 2, 2 ], {\n* 'dtype': 'float32'\n* });\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAc,QAAS,8BAA+B,EACtDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQF,EAAS,IAAK,gBAAiB,EACvCG,EAAQH,EAAS,IAAK,OAAQ,EAgClC,SAASI,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAQ,CAAE,EAEzGb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQL,EAEJT,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQL,EAEJV,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBb,EAAYa,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQL,EACRM,EAAQL,EAET,GAAKZ,EAAUc,CAAM,EACpBS,EAAK,CAAET,CAAM,UACFX,EAAaW,CAAM,EAC9BS,EAAKT,MAEL,OAAM,IAAI,UAAWJ,EAAQ,0HAA2HI,CAAM,CAAE,EAGjK,GADAI,EAAQK,EAAG,OACNL,EAAQ,EAAI,CAEhB,GADAG,EAAMd,EAAOgB,CAAG,EACXF,IAAQA,GAAOA,EAAM,EAEzB,MAAM,IAAI,UAAWX,EAAQ,0HAA2HI,CAAM,CAAE,EAEjKQ,EAAKlB,EAAemB,EAAIN,CAAM,CAC/B,MAECI,EAAM,EACNC,EAAK,CAAE,CAAE,EAGV,GADAF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWV,EAAQ,4EAA6E,QAASM,CAAM,CAAE,EAE5H,OAAO,IAAIR,EAASQ,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKApB,EAAO,QAAUc,IClGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isPlainObject", "hasOwnProp", "isArrayLike", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "defaults", "format", "DTYPE", "ORDER", "zeros", "shape", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4f367c8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( shape[, options] ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - shape: ArrayLikeObject|integer - Array shape. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Underlying data type. Must be a numeric data type or "generic". Default: - 'float64'. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 2, 2 ] ) - - > var sh = arr.shape - [ 2, 2 ] - > var dt = arr.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index de749bf..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,132 +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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - zeros( [ 2, 2 ] ); // $ExpectType float64ndarray - - zeros( [ 2, 2 ], { 'dtype': 'float64' } ); // $ExpectType float64ndarray - zeros( [ 2, 2 ], { 'dtype': 'float32' } ); // $ExpectType float32ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - zeros( [ 2, 2 ], { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - zeros( [ 2, 2 ], { 'dtype': 'int32' } ); // $ExpectType int32ndarray - zeros( [ 2, 2 ], { 'dtype': 'int16' } ); // $ExpectType int16ndarray - zeros( [ 2, 2 ], { 'dtype': 'int8' } ); // $ExpectType int8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - zeros( [ 2, 2 ], { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a valid shape for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [ '5' ] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', {} ); // $ExpectError - zeros( false, {} ); // $ExpectError - zeros( true, {} ); // $ExpectError - zeros( null, {} ); // $ExpectError - zeros( undefined, {} ); // $ExpectError - zeros( [ '5' ], {} ); // $ExpectError - zeros( {}, {} ); // $ExpectError - zeros( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an options argument which is not an object... -{ - zeros( [ 2, 2 ], '5' ); // $ExpectError - zeros( [ 2, 2 ], 5 ); // $ExpectError - zeros( [ 2, 2 ], false ); // $ExpectError - zeros( [ 2, 2 ], true ); // $ExpectError - zeros( [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - zeros( [ 2, 2 ], { 'dtype': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': null } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': undefined } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - zeros( [ 2, 2 ], { 'order': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - zeros( [ 2, 2 ], { 'mode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - zeros( [ 2, 2 ], { 'submode': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': false } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': true } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `readonly` option which is not a boolean... -{ - zeros( [ 2, 2 ], { 'readonly': '5' } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': 5 } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': [ '5' ] } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': {} } ); // $ExpectError - zeros( [ 2, 2 ], { 'readonly': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( [ 2, 2 ], {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 375bd7f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes( 'numeric' ); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b356f1a..0fa38fa 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, genericndarray, complex128ndarray, complex64ndarray, NumericAndGenericDataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e9d57f3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array-like@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var a=l.get("dtypes.default"),j=l.get("order");function h(l){var h,f,v,b,y,g,c,u;if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(p("0kJ2V",h));f=r(h,"dtype")?h.dtype:a,v=r(h,"order")?h.order:j,r(h,"mode")&&(b.mode=h.mode),r(h,"submode")&&(b.submode=h.submode),r(h,"readonly")&&(b.readonly=h.readonly)}else f=a,v=j;if(e(l))u=[l];else{if(!t(l))throw new TypeError(p("0kJ5s",l));u=l}if(u.length>0){if((g=m(u))!=g||g<0)throw new TypeError(p("0kJ5s",l));c=d(u,v)}else g=1,c=[0];if(null===(y=n(f,g)))throw new TypeError(p("0kJBf","dtype",f));return new o(f,y,u,c,i(u,c),v,b)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..41f41da --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport isArrayLike from '@stdlib/assert-is-array-like';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DTYPE = defaults.get( 'dtypes.default' );\nvar ORDER = defaults.get( 'order' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape\n* @param {Options} [options] - options\n* @param {string} [options.dtype='float64'] - data type\n* @param {string} [options.order='row-major'] - array order\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a recognized data type\n* @throws {TypeError} `order` option must be a recognized array order\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( [ 2, 2 ] );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float64'\n*/\nfunction zeros( shape ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0kJ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = DTYPE;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = ORDER;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = DTYPE;\n\t\torder = ORDER;\n\t}\n\tif ( isNumber( shape ) ) {\n\t\tsh = [ shape ];\n\t} else if ( isArrayLike( shape ) ) {\n\t\tsh = shape;\n\t} else {\n\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len !== len || len < 0 ) {\n\t\t\t// We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)...\n\t\t\tthrow new TypeError( format( '0kJ5s', shape ) );\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( '0kJBf', 'dtype', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["DTYPE","defaults","get","ORDER","zeros","shape","options","dtype","order","opts","buf","len","st","sh","arguments","length","isPlainObject","TypeError","format","hasOwnProp","mode","submode","readonly","isNumber","isArrayLike","numel","shape2strides","buffer","ndarray","strides2offset"],"mappings":";;qiCAqCA,IAAIA,EAAQC,EAASC,IAAK,kBACtBC,EAAQF,EAASC,IAAK,SAgC1B,SAASE,EAAOC,GACf,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAO,CAAA,EACFK,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNV,EAAUQ,UAAW,IAEpB,MAAM,IAAIG,UAAWC,EAAQ,QAASZ,IAGtCC,EADIY,EAAYb,EAAS,SACjBA,EAAQC,MAERP,EAGRQ,EADIW,EAAYb,EAAS,SACjBA,EAAQE,MAERL,EAEJgB,EAAYb,EAAS,UACzBG,EAAKW,KAAOd,EAAQc,MAEhBD,EAAYb,EAAS,aACzBG,EAAKY,QAAUf,EAAQe,SAEnBF,EAAYb,EAAS,cACzBG,EAAKa,SAAWhB,EAAQgB,SAE3B,MACEf,EAAQP,EACRQ,EAAQL,EAET,GAAKoB,EAAUlB,GACdQ,EAAK,CAAER,OACD,KAAKmB,EAAanB,GAGxB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAFtCQ,EAAKR,CAGL,CAED,GADQQ,EAAGE,OACE,EAAI,CAEhB,IADAJ,EAAMc,EAAOZ,KACAF,GAAOA,EAAM,EAEzB,MAAM,IAAIM,UAAWC,EAAQ,QAASb,IAEvCO,EAAKc,EAAeb,EAAIL,EAC1B,MAEEG,EAAM,EACNC,EAAK,CAAE,GAGR,GAAa,QADbF,EAAMiB,EAAQpB,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAAS,QAASX,IAEhD,OAAO,IAAIqB,EAASrB,EAAOG,EAAKG,EAAID,EAAIiB,EAAgBhB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 454e806..0000000 --- a/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Create a zero-filled ndarray having a specified shape and data type. -* -* @module @stdlib/ndarray-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var arr = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ - -// 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 8ab5a50..0000000 --- a/lib/main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayLike = require( '@stdlib/assert-is-array-like' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DTYPE = defaults.get( 'dtypes.default' ); -var ORDER = defaults.get( 'order' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} shape - array shape -* @param {Options} [options] - options -* @param {string} [options.dtype='float64'] - data type -* @param {string} [options.order='row-major'] - array order -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only -* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a recognized data type -* @throws {TypeError} `order` option must be a recognized array order -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( [ 2, 2 ] ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -function zeros( shape ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '0kJ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = DTYPE; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = ORDER; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - } - } else { - dtype = DTYPE; - order = ORDER; - } - if ( isNumber( shape ) ) { - sh = [ shape ]; - } else if ( isArrayLike( shape ) ) { - sh = shape; - } else { - throw new TypeError( format( '0kJ5s', shape ) ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len !== len || len < 0 ) { - // We should only get here if we've been provided an invalid shape (e.g., an array containing negative integers, etc)... - throw new TypeError( format( '0kJ5s', shape ) ); - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - buf = buffer( dtype, len ); - if ( buf === null ) { - throw new TypeError( format( '0kJBf', 'dtype', dtype ) ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ae8eaff..7b0480c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a zero-filled ndarray having a specified shape and data type.", "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,59 +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": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..010b937 --- /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 2915a9b..0000000 --- a/test/test.js +++ /dev/null @@ -1,1070 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is neither a nonnegative integer nor an array of nonnegative integers (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [ '5' ], - {}, - 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() { - zeros( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - 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() { - zeros( [ 2, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - 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() { - zeros( [ 2, 2 ], { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( [ 2, 2 ], { - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( [ 2, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 4 ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'row-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'order': 'column-major' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (default; integer shape; dtype=generic)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic' - }; - arr = zeros( 4, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'float32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'int8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint32', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint16', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - opts = { - 'dtype': 'uint8c', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex128', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - opts = { - 'dtype': 'complex64', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( arr.data, 0 ), expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'column-major' - }; - arr = zeros( [ 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0 ] ); - - arr = zeros( [] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports zero-dimensional arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0.0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( [ 2, 0, 2 ] ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports empty arrays (options)', function test( t ) { - var expected; - var opts; - var arr; - - expected = []; - - opts = { - 'dtype': 'generic', - 'order': 'row-major' - }; - arr = zeros( [ 2, 0, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': true - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable arrays', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'readonly': false - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - t.strictEqual( arr.flags.READONLY, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'dtype': 'generic', - 'order': 'row-major', - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - arr = zeros( [ 2, 2, 2 ], opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, opts.dtype, 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, opts.order, 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -});