Skip to content

Commit

Permalink
feat!: refactor namespace to export subnamespaces
Browse files Browse the repository at this point in the history
BREAKING CHANGE: APIs renamed and/or moved to subnamespaces

To migrate, users should consult the list of exports to determine
which properties moved where. Double-precision APIs moved to the
`float64` namespace and single-precision APIs moved to the `float32`
namespace. The following properties were renamed:

- complexCtors => ctors
- complexDataType => dtype
- complexDataTypes => dtypes
- complexPromotionRules => promotionRules
  • Loading branch information
kgryte committed Jul 18, 2024
1 parent ea241a3 commit 565a2ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 197 deletions.
93 changes: 2 additions & 91 deletions lib/node_modules/@stdlib/complex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,67 +39,12 @@ var o = ns;
// returns {...}
```

The namespace constains complex number constructors.
The namespace contains the following APIs:

<!-- <toc keywords="+data, +structure, +types"> -->

<div class="namespace-toc">

- <span class="signature">[`base`][@stdlib/complex/base]</span><span class="delimiter">: </span><span class="description">base (i.e., lower-level) complex number functions.</span>
- <span class="signature">[`complex( real, imag[, dtype] )`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span>
- <span class="signature">[`complexCtors( dtype )`][@stdlib/complex/ctors]</span><span class="delimiter">: </span><span class="description">complex number constructors.</span>
- <span class="signature">[`complexDataType( value )`][@stdlib/complex/dtype]</span><span class="delimiter">: </span><span class="description">return the data type of a complex number.</span>
- <span class="signature">[`complexDataTypes()`][@stdlib/complex/dtypes]</span><span class="delimiter">: </span><span class="description">list of complex number data types.</span>
- <span class="signature">[`complexPromotionRules( [dtype1, dtype2] )`][@stdlib/complex/promotion-rules]</span><span class="delimiter">: </span><span class="description">return the complex number data type with the smallest size and closest "kind" to which data types can be **safely** cast.</span>

</div>
<!-- <toc pattern="*"> -->

<!-- </toc> -->

```javascript
var z = ns.complex( 5.0, 3.0 );
// returns <Complex128>

var str = z.toString();
// returns '5 + 3i'

z = ns.complex( 5.0, 3.0, 'float32' );
// returns <Complex64>

z = new ns.Complex64( 5.0, 3.0 );
// returns <Complex64>
```

In addition, the namespace contains the following functions:

<!-- <toc keywords="-data, -structure, -types"> -->

<div class="namespace-toc">

- <span class="signature">[`conj( z )`][@stdlib/complex/float64/conj]</span><span class="delimiter">: </span><span class="description">return the complex conjugate of a double-precision complex floating-point number.</span>
- <span class="signature">[`conjf( z )`][@stdlib/complex/float32/conj]</span><span class="delimiter">: </span><span class="description">return the complex conjugate of a single-precision complex floating-point number.</span>
- <span class="signature">[`imag( z )`][@stdlib/complex/float64/imag]</span><span class="delimiter">: </span><span class="description">return the imaginary component of a double-precision complex floating-point number.</span>
- <span class="signature">[`imagf( z )`][@stdlib/complex/float32/imag]</span><span class="delimiter">: </span><span class="description">return the imaginary component of a single-precision complex floating-point number.</span>
- <span class="signature">[`real( z )`][@stdlib/complex/float64/real]</span><span class="delimiter">: </span><span class="description">return the real component of a double-precision complex floating-point number.</span>
- <span class="signature">[`realf( z )`][@stdlib/complex/float32/real]</span><span class="delimiter">: </span><span class="description">return the real component of a single-precision complex floating-point number.</span>
- <span class="signature">[`reim( z )`][@stdlib/complex/float64/reim]</span><span class="delimiter">: </span><span class="description">return the real and imaginary components of a double-precision complex floating-point number.</span>
- <span class="signature">[`reimf( z )`][@stdlib/complex/float32/reim]</span><span class="delimiter">: </span><span class="description">return the real and imaginary components of a single-precision complex floating-point number.</span>
- <span class="signature">[`reviveComplex( key, value )`][@stdlib/complex/reviver]</span><span class="delimiter">: </span><span class="description">revive a JSON-serialized complex number.</span>

</div>

<!-- </toc> -->

```javascript
var z = ns.complex( 5.0, 3.0 );
var str = z.toString();
// returns '5 + 3i'

var v = ns.conj( z );
str = v.toString();
// returns '5 - 3i'
```

</section>

<!-- /.usage -->
Expand Down Expand Up @@ -135,40 +80,6 @@ console.log( objectKeys( ns ) );

<section class="links">

<!-- <toc-links> -->

[@stdlib/complex/float64/conj]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/conj

[@stdlib/complex/float32/conj]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/conj

[@stdlib/complex/float64/imag]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/imag

[@stdlib/complex/float32/imag]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/imag

[@stdlib/complex/float64/real]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/real

[@stdlib/complex/float32/real]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/real

[@stdlib/complex/float64/reim]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/reim

[@stdlib/complex/float32/reim]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/reim

[@stdlib/complex/reviver]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/reviver

[@stdlib/complex/base]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/base

[@stdlib/complex/cmplx]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/cmplx

[@stdlib/complex/ctors]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/ctors

[@stdlib/complex/dtype]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/dtype

[@stdlib/complex/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/dtypes

[@stdlib/complex/promotion-rules]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/promotion-rules

<!-- </toc-links> -->

</section>

<!-- /.links -->
122 changes: 16 additions & 106 deletions lib/node_modules/@stdlib/complex/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,148 +55,58 @@ setReadOnly( ns, 'base', require( '@stdlib/complex/base' ) );
setReadOnly( ns, 'complex', require( '@stdlib/complex/cmplx' ) );

/**
* @name complexCtors
* @name ctors
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/ctors}
*/
setReadOnly( ns, 'complexCtors', require( '@stdlib/complex/ctors' ) );
setReadOnly( ns, 'ctors', require( '@stdlib/complex/ctors' ) );

/**
* @name complexDataType
* @name dtype
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/dtype}
*/
setReadOnly( ns, 'complexDataType', require( '@stdlib/complex/dtype' ) );
setReadOnly( ns, 'dtype', require( '@stdlib/complex/dtype' ) );

/**
* @name complexDataTypes
* @name dtypes
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/dtypes}
*/
setReadOnly( ns, 'complexDataTypes', require( '@stdlib/complex/dtypes' ) );
setReadOnly( ns, 'dtypes', require( '@stdlib/complex/dtypes' ) );

/**
* @name conjf
* @name float32
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float32/conj}
*/
setReadOnly( ns, 'conjf', require( '@stdlib/complex/float32/conj' ) );

/**
* @name Complex64
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/complex/float32/ctor}
*/
setReadOnly( ns, 'Complex64', require( '@stdlib/complex/float32/ctor' ) );

/**
* @name imagf
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float32/imag}
*/
setReadOnly( ns, 'imagf', require( '@stdlib/complex/float32/imag' ) );

/**
* @name realf
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float32/real}
*/
setReadOnly( ns, 'realf', require( '@stdlib/complex/float32/real' ) );

/**
* @name reimf
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float32/reim}
*/
setReadOnly( ns, 'reimf', require( '@stdlib/complex/float32/reim' ) );

/**
* @name reviveComplex64
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float32/reviver}
*/
setReadOnly( ns, 'reviveComplex64', require( '@stdlib/complex/float32/reviver' ) );

/**
* @name conj
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float64/conj}
*/
setReadOnly( ns, 'conj', require( '@stdlib/complex/float64/conj' ) );

/**
* @name Complex128
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/complex/float64/ctor}
*/
setReadOnly( ns, 'Complex128', require( '@stdlib/complex/float64/ctor' ) );

/**
* @name imag
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float64/imag}
*/
setReadOnly( ns, 'imag', require( '@stdlib/complex/float64/imag' ) );

/**
* @name real
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float64/real}
*/
setReadOnly( ns, 'real', require( '@stdlib/complex/float64/real' ) );

/**
* @name reim
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float64/reim}
* @type {Namespace}
* @see {@link module:@stdlib/complex/float32}
*/
setReadOnly( ns, 'reim', require( '@stdlib/complex/float64/reim' ) );
setReadOnly( ns, 'float32', require( '@stdlib/complex/float32' ) );

/**
* @name reviveComplex128
* @name float64
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/float64/reviver}
* @type {Namespace}
* @see {@link module:@stdlib/complex/float64}
*/
setReadOnly( ns, 'reviveComplex128', require( '@stdlib/complex/float64/reviver' ) );
setReadOnly( ns, 'float64', require( '@stdlib/complex/float64' ) );

/**
* @name complexPromotionRules
* @name promotionRules
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/complex/promotion-rules}
*/
setReadOnly( ns, 'complexPromotionRules', require( '@stdlib/complex/promotion-rules' ) );
setReadOnly( ns, 'promotionRules', require( '@stdlib/complex/promotion-rules' ) );

/**
* @name reviveComplex
Expand Down

1 comment on commit 565a2ff

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
complex $\color{green}123/123$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}123/123$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.