From b3d07c3b61de44927ac51ccba1c085095a4ccce9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 09:40:55 +0000 Subject: [PATCH 001/102] Auto-generated commit f1369dba26cd387389c87d9392972582c350abc1 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 207 ++++ index.d.ts | 288 ++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 34 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3733 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..655452b --- /dev/null +++ b/README.md @@ -0,0 +1,207 @@ + + +# 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/base/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes]. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-zeros@esm/index.mjs'; +``` + +#### zeros( dtype, shape, order ) + +Creates a zero-filled [ndarray][@stdlib/ndarray/base/ctor] having a specified shape and [data type][@stdlib/ndarray/dtypes]. + +```javascript +var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); +// returns + +var sh = arr.shape; +// returns [ 2, 2 ] + +var dt = arr.dtype; +// returns 'float64' +``` + +The function accepts the following arguments: + +- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. +- **shape**: array shape. +- **order**: specifies whether an [ndarray][@stdlib/ndarray/base/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). + +
+ + + + + +
+ +
+ + + + + +
+ +## 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..2a94473 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,288 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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'; + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'generic' +*/ +declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns zero-filled array +* +* @example +* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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..bc09747 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";var i=s,a=e,m=r,o=t,l=n,j=d;var p=function(s,e,r){var t,n,d;if(e.length>0?(n=j(e),d=i(e,r)):(n=1,d=[0]),null===(t=m(s,n)))throw new TypeError(o("invalid argument. First argument must be a recognized data type. Value: `%s`.",s));return new l(s,t,e,d,a(e,d),r)};export{p as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a81a1cd --- /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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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":["shape2strides","require$$0","strides2offset","require$$1","buffer","require$$2","format","require$$3","ndarray","require$$4","numel","require$$5","lib","dtype","shape","order","buf","len","st","length","TypeError"],"mappings":";;ghBAsBA,IAAIA,EAAgBC,EAChBC,EAAiBC,EACjBC,EAASC,EACTC,EAASC,EACTC,EAAUC,EACVC,EAAQC,EAkDZ,IChCAC,EDMA,SAAgBC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMP,EAAOI,GACbI,EAAKlB,EAAec,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMZ,EAAQS,EAAOI,IAEpB,MAAM,IAAIG,UAAWd,EAAQ,gFAAiFO,IAG/G,OAAO,IAAIL,EAASK,EAAOG,EAAKF,EAAOI,EAAIhB,EAAgBY,EAAOI,GAAMH"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a25e6ed --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "@stdlib/ndarray-base-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-base-zeros.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "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..efee17f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + From cc5d8dfbd28e54747e01ac583e34eb7ea8844f8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:32:09 +0000 Subject: [PATCH 002/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 2a70719becc1465ad073f1e73c4530421ac49cd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 13:26:22 +0000 Subject: [PATCH 003/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 bc09747..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";var i=s,a=e,m=r,o=t,l=n,j=d;var p=function(s,e,r){var t,n,d;if(e.length>0?(n=j(e),d=i(e,r)):(n=1,d=[0]),null===(t=m(s,n)))throw new TypeError(o("invalid argument. First argument must be a recognized data type. Value: `%s`.",s));return new l(s,t,e,d,a(e,d),r)};export{p as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a81a1cd..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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":["shape2strides","require$$0","strides2offset","require$$1","buffer","require$$2","format","require$$3","ndarray","require$$4","numel","require$$5","lib","dtype","shape","order","buf","len","st","length","TypeError"],"mappings":";;ghBAsBA,IAAIA,EAAgBC,EAChBC,EAAiBC,EACjBC,EAASC,EACTC,EAASC,EACTC,EAAUC,EACVC,EAAQC,EAkDZ,IChCAC,EDMA,SAAgBC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMP,EAAOI,GACbI,EAAKlB,EAAec,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMZ,EAAQS,EAAOI,IAEpB,MAAM,IAAIG,UAAWd,EAAQ,gFAAiFO,IAG/G,OAAO,IAAIL,EAASK,EAAOG,EAAKF,EAAOI,EAAIhB,EAAgBY,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index efee17f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From a04189a0f9fa2d0ea8c9172f204afd42123bf98b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 13:26:57 +0000 Subject: [PATCH 004/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 525 ---- 49 files changed, 2713 insertions(+), 5168 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 31d3be6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:41:59.588Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..1128e08 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d997a8c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;yhBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..4982742 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 53e016bfa0cbb15817a7a844882fa8f09b64897b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:43:56 +0000 Subject: [PATCH 005/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 0aef2366636c382b28881fe21ef989724edcaae0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:23:01 +0000 Subject: [PATCH 006/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 1128e08..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d997a8c..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;yhBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4982742..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 6aa5684e6355336880d296b61b89a0fd3323d5c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:23:59 +0000 Subject: [PATCH 007/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 525 ---- 48 files changed, 2713 insertions(+), 5133 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..1128e08 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d997a8c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;yhBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..9299996 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 0253a848f4d8cd2dd691a519422790a34b6b17f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:58:22 +0000 Subject: [PATCH 008/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 830514fb7e3e3835d65e77095b70c06b8de673ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:44:02 +0000 Subject: [PATCH 009/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 1128e08..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d997a8c..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;yhBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9299996..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From ddf995aaccb7ed4ff80aa75b59054a06d8c74b81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:44:53 +0000 Subject: [PATCH 010/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 525 ---- 49 files changed, 2713 insertions(+), 5207 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 54e4cbf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:44:09.327Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1f4a24d --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..27d5c90 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 14cdc19c4096468114557b1ea2f53be9329987bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:49:25 +0000 Subject: [PATCH 011/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 6d3dc33ba222979cd8e73fe9baa054e17aac1603 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:23:50 +0000 Subject: [PATCH 012/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1f4a24d..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27d5c90..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From c6aed315d4069c4d38743b2b8e7dfa85d0345e65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:24:40 +0000 Subject: [PATCH 013/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 525 ---- 49 files changed, 2713 insertions(+), 5223 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 248d26a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:44:20.884Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1f4a24d --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..8c93a3c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 3e777031d4653a4a851ee6599c2537d1366ea8d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:18:05 +0000 Subject: [PATCH 014/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 0fd146de4b7b1be81fd7c915779011816f9eb726 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:14:32 +0000 Subject: [PATCH 015/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1f4a24d..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8c93a3c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From bc7efe36fb9c675aa78fa8eb81c646ddc8d97143 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:15:21 +0000 Subject: [PATCH 016/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 525 ---- 49 files changed, 2713 insertions(+), 5223 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 e7f746d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:12:00.004Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1f4a24d --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..4075cf1 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From bdddea2ce85236a647f48629579ce79fcb7eab99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:02:00 +0000 Subject: [PATCH 017/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 122b633a46b38ed0923188ae407283527de33916 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:06:59 +0000 Subject: [PATCH 018/102] Remove files --- index.d.ts | 288 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2982 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1f4a24d..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4075cf1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 1190bf0d4b66edf497f92248eb06120ce5d95e00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:07:43 +0000 Subject: [PATCH 019/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 525 --- 49 files changed, 4068 insertions(+), 5223 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 9e37504..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:57:23.454Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 cf357a7..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - 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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..90c65cc --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..488dc21 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From b5b8e542c3308d25da35cc20c9bff6370d11f0cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:42:03 +0000 Subject: [PATCH 020/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index b76d80e..02d6b01 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From f061e0ce626160113431163225565a9f9a3026b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:42:03 +0000 Subject: [PATCH 021/102] Remove files --- index.d.ts | 288 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4337 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 90c65cc..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 488dc21..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From be6d36688dbda0dab3a000dcd052ea093058d466 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:42:51 +0000 Subject: [PATCH 022/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 525 --- 49 files changed, 4068 insertions(+), 5244 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 e66e63f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:59:20.468Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 cf357a7..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - 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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..90c65cc --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 02d6b01..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..a9b58fb --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 90d7271144b3e444d15fdcf222815046a29f9062 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:40:59 +0000 Subject: [PATCH 023/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 62fe72c..7195bed 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 07ee8558a022f568e1be067488f5bf93d834b461 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:46:59 +0000 Subject: [PATCH 024/102] Remove files --- index.d.ts | 288 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4337 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 90c65cc..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 shape2strides from '@stdlib/ndarray-base-shape2strides' ;\nimport strides2offset from '@stdlib/ndarray-base-strides2offset' ;\nimport buffer from '@stdlib/ndarray-base-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport ndarray from '@stdlib/ndarray-base-ctor' ;\nimport numel from '@stdlib/ndarray-base-numel' ;\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a9b58fb..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From d2b6d1a30e1962ee09c6da30bfad663a35da4fa4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:47:55 +0000 Subject: [PATCH 025/102] 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 | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 525 --- 49 files changed, 4068 insertions(+), 5249 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 dff7feb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:47:53.858Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 cf357a7..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - 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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..60411f4 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e71bbea --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 7195bed..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..29648f7 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 1453f6991b25c7cad3543c30c70748a553069c41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:21:45 +0000 Subject: [PATCH 026/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..6563d5d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0Mn5Y', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 35699ba..1fc35df 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.0.x", "@stdlib/ndarray-base-shape2strides": "^0.0.x", "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 020708adff52715702098c3a94536cdde1a29962 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:22:54 +0000 Subject: [PATCH 027/102] Remove files --- index.d.ts | 288 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4337 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 60411f4..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e71bbea..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29648f7..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From d123eedf16040876366c7c311e5e7bae66c0eac5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:23:50 +0000 Subject: [PATCH 028/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 525 -- 49 files changed, 6201 insertions(+), 5260 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 033a682..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:29:03.843Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 cf357a7..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - 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 + + ```
@@ -146,7 +139,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]. @@ -206,9 +199,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d861167..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/base/zeros" -click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 3464925..2a94473 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..4e6bb03 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e71bbea --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 6563d5d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0Mn5Y', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1fc35df..c7f2aa5 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.0.x", - "@stdlib/ndarray-base-ctor": "^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/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..c97e67a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From c63846ec78b5a9e3d0eca42d268f94b9f0cfc4fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 15:58:18 +0000 Subject: [PATCH 029/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 84ec79d..d8ebd75 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.0", "@stdlib/ndarray-base-shape2strides": "^0.1.0", "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From ea434498f1495d74d8d12760196284246782c1ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:13:08 +0000 Subject: [PATCH 030/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 2a94473..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 4e6bb03..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0Mn5Y",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e71bbea..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0Mn5Y', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;giBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c97e67a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 79ad03353cdfad3a0152c2ec6a1d0bfc25d86f5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:13:56 +0000 Subject: [PATCH 031/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 525 -- 52 files changed, 6201 insertions(+), 5435 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 44b1759..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/base/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 cf357a7..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - 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 + + ```
@@ -157,7 +150,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]. @@ -217,9 +210,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 2abff49..6cbb98a 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6a4c3af --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d593348 --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;4jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d8ebd75..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.0", - "@stdlib/ndarray-base-ctor": "^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/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..fc43384 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 270a61f275265d9c791dba532979175c8580f575 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:21:38 +0000 Subject: [PATCH 032/102] 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 0352b94..3a3362d 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-base-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-zeros@v0.1.0-esm/index.mjs'; ``` #### zeros( dtype, shape, order ) @@ -103,7 +103,7 @@ The function accepts the following arguments: - - - - From c4f2b4ffa835b8f596b44397e48bd3a3aba091aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 01:30:21 +0000 Subject: [PATCH 036/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 525 -- test/test.js | 525 -- 54 files changed, 6201 insertions(+), 6019 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 2e29894..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:16:11.982Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -157,7 +150,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]. @@ -217,9 +210,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 2abff49..6cbb98a 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1e6a08a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 14e48c3..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^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/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..1e11511 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 4bea6ac..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 1b37c32e21a69bd57365ee59a6f7249aced4bfdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 19:38:04 +0000 Subject: [PATCH 037/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index d307bf2..85101c4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From c0df04754be24f7c5d137e0782d7f1c44a4cbbcf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:26:55 +0000 Subject: [PATCH 038/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 6cbb98a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 1e6a08a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1e11511..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 256c87f961a4cde6d0727e7195169d9638ea6655 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:27:43 +0000 Subject: [PATCH 039/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 525 -- test/test.js | 525 -- 53 files changed, 6201 insertions(+), 6018 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -157,7 +150,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]. @@ -217,9 +210,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 2abff49..6cbb98a 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..848495c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 85101c4..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..c15d5df --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 4bea6ac..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 392b76585e2b5fc3fc19acd2d8d7815d6103df0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:16:48 +0000 Subject: [PATCH 040/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 9c667cf..b287381 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 24324d037d18db35a28dcd087c4cf912a640f4eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:45:36 +0000 Subject: [PATCH 041/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 6cbb98a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 848495c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c15d5df..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 1dbe78906111788740f08a67a2de7802eef6fe62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:46:21 +0000 Subject: [PATCH 042/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 54 files changed, 6201 insertions(+), 5535 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 14ff6fb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:34:27.648Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -157,7 +150,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]. @@ -217,9 +210,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/base/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 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - 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 2abff49..6cbb98a 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..848495c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index b287381..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..4a52d4e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 1f349459046e778ed6b297b2a61481b7b4126f32 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 11:28:28 +0000 Subject: [PATCH 043/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index d326010..efcfcd6 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 388dee9b3305a1479434b5302b03992549aada8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:01:47 +0000 Subject: [PATCH 044/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 6cbb98a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; // tslint:disable-line:max-line-length - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): 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 848495c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4a52d4e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 9de324985bb4da288239aa6fc09cb467e4799a3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 15:02:32 +0000 Subject: [PATCH 045/102] 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 | 41 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 53 files changed, 6202 insertions(+), 5535 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +157,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]. @@ -224,13 +217,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index fb8e90e..dd0d575 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..848495c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index efcfcd6..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..0b3e77b --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From a90db39e20df69e639c50ba28952c4d6cd8ec7b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:41:42 +0000 Subject: [PATCH 046/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index ce66870..ac17f91 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 40d9066250a8ee1daaa95628f2a8c1c357a97192 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:42:46 +0000 Subject: [PATCH 047/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 dd0d575..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; unified-signatures - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 848495c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b3e77b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From b7213696deb07fad2a95aa13489a6d5209cb626d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Nov 2023 19:43:40 +0000 Subject: [PATCH 048/102] 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 | 41 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 53 files changed, 6202 insertions(+), 5535 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +157,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]. @@ -224,13 +217,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..848495c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ac17f91..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..c2414b1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 311f201de8a17397c9e4bd82a0cc665b0d4a4ece Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:25:31 +0000 Subject: [PATCH 049/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..b049259 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K,L8', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index ce66870..ac17f91 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 4008bc3f3aa68312d6f0bad60310f21a49171865 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:31:53 +0000 Subject: [PATCH 050/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 848495c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c2414b1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From e93c7feda0ebd6a1e052750511e9ac7fb7aa12ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:32:40 +0000 Subject: [PATCH 051/102] 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 | 41 +- benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 54 files changed, 6202 insertions(+), 5531 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 (98%) 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 5e144f4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:39:22.145Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 124405f..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +157,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]. @@ -224,13 +217,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 28a2141..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 7d162b3..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 91bb73f..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2299391..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 00e77f5..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 adca583..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c7f461..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 08b34a0..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bce0947..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 2254d97..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f884da9..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9c3df66..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 42a040e..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..848495c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b9bb15c --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 b049259..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K,L8', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ac17f91..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..95bfcfd --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 1573a5b25d855603a597040e42f2cea8f2e0434d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 07:59:38 +0000 Subject: [PATCH 052/102] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aa9402b..5258d93 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 817aa6e5a8e8e1b6f2baef7862b7fac1f2686c12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:36:05 +0000 Subject: [PATCH 053/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 848495c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K,L8",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b9bb15c..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K,L8', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,WAAYX,IAG1C,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 95bfcfd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 3fe2804e920fc1c5692760196a780b0cd26bf533 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:36:29 +0000 Subject: [PATCH 054/102] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 55 files changed, 6202 insertions(+), 5537 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 (98%) 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 3d99c46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:08:44.341Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 9aed565..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -164,7 +157,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]. @@ -224,13 +217,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1e436c2..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/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abbf7dd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,a){var o,l,j;if(m.length>0?(l=d(m),j=s(m,a)):(l=1,j=[0]),null===(o=t(i,l)))throw new TypeError(r("invalid argument. First argument must be a recognized data type. Value: `%s`.",i));return new n(i,o,m,j,e(m,j),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e3dacc1 --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/string-format';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;0jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,gFAAiFX,IAG/G,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a313629..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 5258d93..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..766a015 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From a436e34d31cc946dd13e26ebb00bcb81aeb7e7cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:31:37 +0000 Subject: [PATCH 055/102] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aa9402b..5258d93 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.1.1", "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From f4bc5be61225bd884414235c0a33d6d9e8242ac6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:57:22 +0000 Subject: [PATCH 056/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abbf7dd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,a){var o,l,j;if(m.length>0?(l=d(m),j=s(m,a)):(l=1,j=[0]),null===(o=t(i,l)))throw new TypeError(r("invalid argument. First argument must be a recognized data type. Value: `%s`.",i));return new n(i,o,m,j,e(m,j),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e3dacc1..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/string-format';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;0jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,gFAAiFX,IAG/G,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 766a015..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From af87a75181c0b1e0f86785603c82b84d8369f579 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:57:38 +0000 Subject: [PATCH 057/102] 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 | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 55 files changed, 6202 insertions(+), 5542 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 (98%) 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 46ed90b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T05:58:21.175Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 9aed565..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abbf7dd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,a){var o,l,j;if(m.length>0?(l=d(m),j=s(m,a)):(l=1,j=[0]),null===(o=t(i,l)))throw new TypeError(r("invalid argument. First argument must be a recognized data type. Value: `%s`.",i));return new n(i,o,m,j,e(m,j),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e3dacc1 --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/string-format';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;0jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,gFAAiFX,IAG/G,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a313629..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 5258d93..49b1d5e 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.1.1", - "@stdlib/ndarray-base-ctor": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^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..73dc791 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 3e4d71943cc30110e606948e00c599dad4c5177a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:11:14 +0000 Subject: [PATCH 058/102] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aa7c460..110b928 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.0", "@stdlib/ndarray-base-shape2strides": "^0.2.0", "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From dfa9c5c8c35ef30af5e95483fc33e7f4ec5b572c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:58:30 +0000 Subject: [PATCH 059/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6470 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abbf7dd..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";function i(i,m,a){var o,l,j;if(m.length>0?(l=d(m),j=s(m,a)):(l=1,j=[0]),null===(o=t(i,l)))throw new TypeError(r("invalid argument. First argument must be a recognized data type. Value: `%s`.",i));return new n(i,o,m,j,e(m,j),a)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e3dacc1..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/string-format';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;0jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,gFAAiFX,IAG/G,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 73dc791..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From eb4942a275a8131df79a0fe38684c9d2f21c6cba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:58:59 +0000 Subject: [PATCH 060/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 74 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 54 files changed, 6202 insertions(+), 5545 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 ca734f0..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4e6d0aa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,a){var o,l,j;if(m.length>0?(l=d(m),j=s(m,a)):(l=1,j=[0]),null===(o=t(i,l)))throw new TypeError(r("invalid argument. First argument must be a recognized data type. Value: `%s`.",i));return new n(i,o,m,j,e(m,j),a)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e3dacc1 --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/string-format';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;0jBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,gFAAiFX,IAG/G,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a313629..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 110b928..cc64018 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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.0", - "@stdlib/ndarray-base-ctor": "^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/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..52157a0 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 780eb981c5daf6a5c9392539de4b2fb69776b0f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:43:07 +0000 Subject: [PATCH 061/102] 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 7e6483b..685f62a 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-base-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-zeros@v0.2.0-esm/index.mjs'; ``` #### zeros( dtype, shape, order ) @@ -103,7 +103,7 @@ The function accepts the following arguments: - - - - From 3ee40d99a74e5a4d0ce06fef7a35c1354236079a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:52:13 +0000 Subject: [PATCH 065/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 54 files changed, 4867 insertions(+), 5540 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6c7a4f7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..44d8c1f --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 245e014..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 411ee9e..778234d 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^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/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..94e45c5 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From beb5be10e7d71ac232a3f9aba0ce34e34a7fa5f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:25:04 +0000 Subject: [PATCH 066/102] 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 6022108..514eab5 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-base-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-zeros@v0.2.1-esm/index.mjs'; ``` #### zeros( dtype, shape, order ) @@ -103,7 +103,7 @@ The function accepts the following arguments: - - - - From c224143c5c0430ca79e1486002d6df224062d989 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:32:08 +0000 Subject: [PATCH 070/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5542 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 (98%) 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 a52be6f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:40:38.622Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fde3d22 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..44d8c1f --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 245e014..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2d954cb..778234d 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^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/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..4b2d8ac --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 0981a479a6e1c6ba015226a09210383d513ff519 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:09:53 +0000 Subject: [PATCH 071/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..245e014 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 78348de..2d954cb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^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 afa95a2fb6e2107c667f85800f9236159e10df02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:29:13 +0000 Subject: [PATCH 072/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fde3d22..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 44d8c1f..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b2d8ac..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 70fff6e14f03a729e367be232270d563c5c4dfed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:29:29 +0000 Subject: [PATCH 073/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5545 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 (98%) 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 dd8f16b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T04:58:55.963Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fde3d22 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..44d8c1f --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 245e014..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2d954cb..778234d 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^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/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..4b2d8ac --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 00932fb4b0cc364969906a68f4fb0a74f623e76b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:27:43 +0000 Subject: [PATCH 074/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index a313629..245e014 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 78348de..2d954cb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^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 a9381a94ff917280a040e3f0146774fe3e34853a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:48:17 +0000 Subject: [PATCH 075/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fde3d22..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 44d8c1f..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b2d8ac..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From e43700ea85a233df77c3474c7135ffe30238dc50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:48:34 +0000 Subject: [PATCH 076/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 54 files changed, 4867 insertions(+), 5546 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 fa8bb25..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7636575..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 f214858..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType typedndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0f277d8..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 9968951..de7d9f6 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fde3d22 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..44d8c1f --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 245e014..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2d954cb..778234d 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^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/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..4b2d8ac --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 913b20b..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 5cd264f54f128f8ce640b2af6060da98505f04b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:32:48 +0000 Subject: [PATCH 077/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 78348de..2d954cb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.1", "@stdlib/ndarray-base-shape2strides": "^0.2.1", "@stdlib/ndarray-base-strides2offset": "^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 e66ceed48883f4df0c2c8d861b04a4a611381627 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:33:56 +0000 Subject: [PATCH 078/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 de7d9f6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): typedndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: DataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fde3d22..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 44d8c1f..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b2d8ac..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From fa7a4e0e727c19b9030058d6bd058df8dbd8f359 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:34:10 +0000 Subject: [PATCH 079/102] 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 | 120 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 54 files changed, 4867 insertions(+), 5672 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fde3d22 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 2d954cb..778234d 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^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/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..ce04046 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 101afcb0f3fbf00dfcfc2c8d26aa942e74739e4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:43:44 +0000 Subject: [PATCH 080/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 7d77104..b8dd036 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@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 54236a33fc7012726b673b888fcf26585ddeffd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:51:07 +0000 Subject: [PATCH 081/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fde3d22..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@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";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ce04046..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From c42646c5221ead95caac60871881cad80b0477ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:51:31 +0000 Subject: [PATCH 082/102] 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 | 173 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 54 files changed, 4867 insertions(+), 5727 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 (98%) 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 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ae182fd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index b8dd036..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.2.1", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@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..9eaddb3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 8b7e69da4d1f62eb79c00739cd76da280123efce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:57:17 +0000 Subject: [PATCH 083/102] 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 faa5c90..ffae45f 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-base-zeros@esm/index.mjs'; +import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-zeros@v0.3.0-esm/index.mjs'; ``` #### zeros( dtype, shape, order ) @@ -103,7 +103,7 @@ The function accepts the following arguments: - - - - From 44f833a72b229bb9a5901f932d220c1bb1f143c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 12:51:23 +0000 Subject: [PATCH 087/102] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5643 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 (98%) 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 4671256..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T05:51:13.251Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc35636 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 8d212ff..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 19b5a023832360c7d8f323edeff0fcb9dea74030 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:21:50 +0000 Subject: [PATCH 088/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 917a37e..d9dcd60 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From ae30374f637737288526c42f18d837bb83269f78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:45:49 +0000 Subject: [PATCH 089/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc35636..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0eb3cc4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 67785213e3a0ccd1868d21f874293c73ada9dafc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:46:06 +0000 Subject: [PATCH 090/102] 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 | 172 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5727 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 (98%) 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 56a8a4f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:17:47.579Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc35636 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d9dcd60..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 8315ae088c9b64efb6d7d4976f2fe051235aecae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:39:09 +0000 Subject: [PATCH 091/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 917a37e..d9dcd60 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 8a9c041ca8a3e701c8433c0c719831eea662d95a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:20:35 +0000 Subject: [PATCH 092/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc35636..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0eb3cc4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From e676c4867fe9eea440d0384e88021444120a056f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:20:50 +0000 Subject: [PATCH 093/102] 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 | 172 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5727 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 (98%) 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 d328124..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T06:29:57.527Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc35636 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d9dcd60..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 0694dc9621f623bda84ed1a406732257730c909e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:25:41 +0000 Subject: [PATCH 094/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 917a37e..d9dcd60 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From ce791b5dd4ce6ad2655a532ca3dd1b3abb1e6d1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:25:30 +0000 Subject: [PATCH 095/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc35636..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0eb3cc4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From faf275a60b4faf07c18737d8b082323160d39ed8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:25:44 +0000 Subject: [PATCH 096/102] 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 | 172 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 -- benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 --- 55 files changed, 4867 insertions(+), 5727 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 (98%) 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 a21ba0c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T06:33:09.773Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc35636 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index d9dcd60..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From b2cf7327e7a489bfbf9d50c177447ee2ea6b9a65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:42:33 +0000 Subject: [PATCH 097/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 0558f84..dd81666 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From c156b6bfd5d279d1ded86b1c656f002b03aa9316 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 12:49:56 +0000 Subject: [PATCH 098/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc35636..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0eb3cc4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From ff0e6ad23fbd35b2398b196cc5f6eedb72477096 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 12:50:14 +0000 Subject: [PATCH 099/102] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 172 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 56 files changed, 4867 insertions(+), 5832 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 (98%) 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 9b32622..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T06:42:55.162Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 03d3b92..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dc35636 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index dd81666..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -}); From 2f08732f3e9674a5cd9b4d1a590167cad37a4652 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Jun 2025 15:22:36 +0000 Subject: [PATCH 100/102] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d21c7a2..a9d656a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var ndarray = require( '@stdlib/ndarray-base-ctor' ); var numel = require( '@stdlib/ndarray-base-numel' ); @@ -66,7 +66,7 @@ function zeros( dtype, shape, order ) { } buf = buffer( dtype, len ); if ( buf === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '0jl5K', dtype ) ); } return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 0558f84..dd81666 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-numel": "^0.2.2", "@stdlib/ndarray-base-shape2strides": "^0.2.2", "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 1dbe14cf0bc0d724cd713d9ecdf7a4e096161f51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Jun 2025 15:22:59 +0000 Subject: [PATCH 101/102] Remove files --- index.d.ts | 288 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5135 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 6ffe0f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 } from '@stdlib/types/ndarray'; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: 'float64', shape: Shape, order: Order ): float64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -declare function zeros( dtype: 'float32', shape: Shape, order: Order ): float32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex128' -*/ -declare function zeros( dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'complex64' -*/ -declare function zeros( dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int32' -*/ -declare function zeros( dtype: 'int32', shape: Shape, order: Order ): int32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int16' -*/ -declare function zeros( dtype: 'int16', shape: Shape, order: Order ): int16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'int8' -*/ -declare function zeros( dtype: 'int8', shape: Shape, order: Order ): int8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint32' -*/ -declare function zeros( dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint16' -*/ -declare function zeros( dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8' -*/ -declare function zeros( dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'uint8c' -*/ -declare function zeros( dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'generic' -*/ -declare function zeros( dtype: 'generic', shape: Shape, order: Order ): genericndarray; - -/** -* Creates a zero-filled array having a specified shape and data type. -* -* @param dtype - underlying data type -* @param shape - array shape -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns zero-filled array -* -* @example -* var arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float64' -*/ -declare function zeros( dtype: NumericAndGenericDataType, shape: Shape, order: Order ): typedndarray; - - -// EXPORTS // - -export = zeros; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dc35636..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8187eff..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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0eb3cc4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Codestin Search App - - - -
- - - - - From 55466b83e99a4d0739a09f998de677df5035f6df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Jun 2025 15:23:44 +0000 Subject: [PATCH 102/102] 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 | 218 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 245 - benchmark/benchmark.size.complex128.js | 93 - benchmark/benchmark.size.complex64.js | 93 - benchmark/benchmark.size.float32.js | 93 - benchmark/benchmark.size.float64.js | 93 - benchmark/benchmark.size.generic.js | 93 - benchmark/benchmark.size.int16.js | 93 - benchmark/benchmark.size.int32.js | 93 - benchmark/benchmark.size.int8.js | 93 - benchmark/benchmark.size.uint16.js | 93 - benchmark/benchmark.size.uint32.js | 93 - benchmark/benchmark.size.uint8.js | 93 - benchmark/benchmark.size.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 33 - docs/types/test.ts | 94 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 78 - package.json | 75 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 525 -- 55 files changed, 4867 insertions(+), 5880 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 (98%) 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 dab745c..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 c4bf013..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/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 dab9f1b..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: '26 14 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -166,7 +157,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]. @@ -229,13 +220,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-zeros/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-zeros-like +[@stdlib/ndarray/base/zeros-like]: https://github.com/stdlib-js/ndarray-base-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 45c59fd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,245 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'float32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex128', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'complex64', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint32', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint16', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'int8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'uint8c', [ 0 ], 'row-major' ); - if ( arr.length !== 0 ) { - b.fail( '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( 'generic', [ 0 ], 'row-major' ); - if ( arr.length !== 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 41b433b..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex128', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 74059b9..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'complex64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 5fac9d8..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 134b41f..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'float64', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 65153cf..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'generic', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 7f2de12..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b5c5bef..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9a8018c..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'int8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4dd168b..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint16', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f7108d8..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint32', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 1110ac3..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 b3ca477..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 'uint8c', [ len ], 'row-major' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 0b2b90b..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros" -%% click B href "https://github.com/stdlib-js/ndarray-base-zeros/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-zeros/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-zeros/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-zeros/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-zeros/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/zeros -[production-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-zeros/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-zeros/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-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 ab047dd..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(x,s){ -var l=require('@stdlib/ndarray-base-shape2strides/dist'),o=require('@stdlib/ndarray-base-strides2offset/dist'),m=require('@stdlib/ndarray-base-buffer/dist'),q=require('@stdlib/error-tools-fmtprodmsg/dist'),c=require('@stdlib/ndarray-base-ctor/dist'),d=require('@stdlib/ndarray-base-numel/dist');function g(e,r,u){var n,a,t,i;if(n=r.length,n>0?(t=d(r),i=l(r,u)):(t=1,i=[0]),a=m(e,t),a===null)throw new TypeError(q('0jl5K',e));return new c(e,a,r,i,o(r,i),u)}s.exports=g -});var b=v();module.exports=b; -/** @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 afe003c..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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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 argument. First argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), 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-base-zeros\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-base-zeros' );\n*\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\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,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,2BAA4B,EAC/CC,EAAQ,QAAS,4BAA6B,EAwBlD,SAASC,EAAOC,EAAOC,EAAOC,EAAQ,CACrC,IAAIC,EACAC,EACAC,EACAC,EAYJ,GAVAH,EAAQF,EAAM,OACTE,EAAQ,GACZE,EAAMP,EAAOG,CAAM,EACnBK,EAAKb,EAAeQ,EAAOC,CAAM,IAGjCG,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMT,EAAQK,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,gFAAiFI,CAAM,CAAE,EAGvH,OAAO,IAAIH,EAASG,EAAOI,EAAKH,EAAOK,EAAIZ,EAAgBO,EAAOK,CAAG,EAAGJ,CAAM,CAC/E,CAKAV,EAAO,QAAUO,ICrCjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "shape2strides", "strides2offset", "buffer", "format", "ndarray", "numel", "zeros", "dtype", "shape", "order", "ndims", "buf", "len", "st", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 86caf36..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( dtype, shape, order ) - Returns a zero-filled ndarray having a specified shape and data type. - - Parameters - ---------- - dtype: string - Underlying data type. Must be a numeric data type or "generic". - - shape: ArrayLikeObject - Array shape. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major' ) - - > 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 704bc51..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - - zeros( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray - zeros( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray - zeros( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray - zeros( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray - zeros( 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray - zeros( 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray - zeros( 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray - zeros( 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray - zeros( 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray - zeros( 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray - zeros( 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray - zeros( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... -{ - zeros( '10', [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( 10, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( false, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( true, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( null, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( [], [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( {}, [ 2, 2 ], 'row-major' ); // $ExpectError - zeros( ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid shape for the second argument... -{ - zeros( 'float32', '5', 'row-major' ); // $ExpectError - zeros( 'float32', false, 'row-major' ); // $ExpectError - zeros( 'float32', true, 'row-major' ); // $ExpectError - zeros( 'float32', null, 'row-major' ); // $ExpectError - zeros( 'float32', undefined, 'row-major' ); // $ExpectError - zeros( 'float32', [ '5' ], 'row-major' ); // $ExpectError - zeros( 'float32', {}, 'row-major' ); // $ExpectError - zeros( 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid order for the third argument... -{ - zeros( 'float32', [ 2, 2 ], '5' ); // $ExpectError - zeros( 'float32', [ 2, 2 ], false ); // $ExpectError - zeros( 'float32', [ 2, 2 ], true ); // $ExpectError - zeros( 'float32', [ 2, 2 ], null ); // $ExpectError - zeros( 'float32', [ 2, 2 ], undefined ); // $ExpectError - zeros( 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError - zeros( 'float32', [ 2, 2 ], {} ); // $ExpectError - zeros( 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 'float64' ); // $ExpectError - zeros( 'float64', [ 2, 2 ] ); // $ExpectError - zeros( 'float64', [ 2, 2 ], 'row-major', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99d2c21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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( dt[ i ], [ 2, 2 ], 'row-major' ); - console.log( arr.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 0831527..6ffe0f0 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 } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d3978fd --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";function i(i,m,o){var a,j,l;if(m.length>0?(j=n(m),l=s(m,o)):(j=1,l=[0]),null===(a=e(i,j)))throw new TypeError(t("0jl5K",i));return new d(i,a,m,l,r(m,l),o)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8187eff --- /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 shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport ndarray from '@stdlib/ndarray-base-ctor';\nimport numel from '@stdlib/ndarray-base-numel';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having a specified shape and data type.\n*\n* @param {string} dtype - numeric data type\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - array order\n* @throws {TypeError} first argument must be a recognized data type\n* @returns {ndarray} ndarray\n*\n* @example\n* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' );\n* // returns \n*\n* var sh = arr.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = arr.dtype;\n* // returns 'float32'\n*/\nfunction zeros( dtype, shape, order ) {\n\tvar ndims;\n\tvar buf;\n\tvar len;\n\tvar st;\n\n\tndims = shape.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( shape );\n\t\tst = shape2strides( shape, 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( '0jl5K', dtype ) );\n\t}\n\n\treturn new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["zeros","dtype","shape","order","buf","len","st","length","numel","shape2strides","buffer","TypeError","format","ndarray","strides2offset"],"mappings":";;mkBAmDA,SAASA,EAAOC,EAAOC,EAAOC,GAC7B,IACIC,EACAC,EACAC,EAYJ,GAVQJ,EAAMK,OACD,GACZF,EAAMG,EAAON,GACbI,EAAKG,EAAeP,EAAOC,KAG3BE,EAAM,EACNC,EAAK,CAAE,IAGK,QADbF,EAAMM,EAAQT,EAAOI,IAEpB,MAAM,IAAIM,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIY,EAASZ,EAAOG,EAAKF,EAAOI,EAAIQ,EAAgBZ,EAAOI,GAAMH,EACzE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ad142a8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-zeros -* -* @example -* var zeros = require( '@stdlib/ndarray-base-zeros' ); -* -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // 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 a9d656a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var numel = require( '@stdlib/ndarray-base-numel' ); - - -// MAIN // - -/** -* Creates a zero-filled ndarray having a specified shape and data type. -* -* @param {string} dtype - numeric data type -* @param {NonNegativeIntegerArray} shape - array shape -* @param {string} order - array order -* @throws {TypeError} first argument must be a recognized data type -* @returns {ndarray} ndarray -* -* @example -* var arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); -* // returns -* -* var sh = arr.shape; -* // returns [ 2, 2 ] -* -* var dt = arr.dtype; -* // returns 'float32' -*/ -function zeros( dtype, shape, order ) { - var ndims; - var buf; - var len; - var st; - - ndims = shape.length; - if ( ndims > 0 ) { - len = numel( shape ); - st = shape2strides( shape, 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( '0jl5K', dtype ) ); - } - - return new ndarray( dtype, buf, shape, st, strides2offset( shape, st ), order ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index dd81666..3d2da41 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-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..0eb3cc4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Codestin Search App + + + +
+ + + + + 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 6df912d..0000000 --- a/test/test.js +++ /dev/null @@ -1,525 +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-base-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 an unrecognized 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( value, 10, 'row-major' ); - }; - } -}); - -tape( 'the function returns a zero-filled array (dtype=float64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'row-major' ); - 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 (dtype=float64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float64', [ 2, 2 ], 'column-major' ); - 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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'float32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'int8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint32', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint16', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - - arr = zeros( 'uint8c', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex128', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 'complex64', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', '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, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=row-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'row-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, order=column-major)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0 ]; - - arr = zeros( 'generic', [ 2, 2 ], 'column-major' ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', '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, 'column-major', '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( 'float64', [], 'row-major' ); - 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 empty arrays', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = zeros( 'float64', [ 2, 0, 2 ], 'row-major' ); - 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(); -});