Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Dec 15, 2024
1 parent 5069873 commit 59851e1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 72 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-12-14)
## Unreleased (2024-12-15)

<section class="packages">

Expand Down Expand Up @@ -317,6 +317,7 @@ A total of 3 people contributed to this release. Thank you to the following cont

<details>

- [`0d6bf75`](https://github.com/stdlib-js/stdlib/commit/0d6bf755cd3fcefbdf4751bc1f8e011bedefc057) - **refactor:** resolve error constructor and add todos _(by Athan Reines)_
- [`dbfd8f5`](https://github.com/stdlib-js/stdlib/commit/dbfd8f5c81d11be2142ebfc4f2f0bb0316ba7478) - **feat:** add `filterMap` to namespace _(by Athan Reines)_
- [`6ff153f`](https://github.com/stdlib-js/stdlib/commit/6ff153f9023cffac527b3243489e6413e989e940) - **feat:** add `ndarray/filter-map` _(by Athan Reines)_
- [`8d1be60`](https://github.com/stdlib-js/stdlib/commit/8d1be60be03dae4a293d0a2967ab2539d759a498) - **refactor:** remove unnecessary variable _(by Athan Reines)_
Expand Down
53 changes: 0 additions & 53 deletions fancy/lib/error_constructor.js

This file was deleted.

7 changes: 2 additions & 5 deletions fancy/lib/get_slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

var slice = require( './../../base/slice' );
var errMessage = require( './error_message.js' );
var errConstructor = require( './error_constructor.js' );


// MAIN //
Expand All @@ -39,18 +38,16 @@ var errConstructor = require( './error_constructor.js' );
* @throws {RangeError} number of slice dimensions must match the number of array dimensions
* @returns {FancyArray} result
*/
function getSlice( target, property, receiver, prop2slice ) { // eslint-disable-line stdlib/jsdoc-require-throws-tags
function getSlice( target, property, receiver, prop2slice ) {
var strict;
var E;
var s;

strict = false; // TODO: support strict mode
s = prop2slice( target, property, strict );
try {
return slice( receiver, s, strict, false );
} catch ( err ) {
E = errConstructor( err );
throw new E( errMessage( err.message ) );
throw new err.constructor( errMessage( err.message ) );
}
}

Expand Down
4 changes: 2 additions & 2 deletions fancy/lib/prop2slice.0d.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function prop2slice( target, property ) {
// Case: slice
if ( ch === 'S' ) {
// Convert the string to a slice object:
s = str2slice( property );
s = str2slice( prop );
if ( s === null ) {
throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) );
}
Expand Down Expand Up @@ -104,7 +104,7 @@ function prop2slice( target, property ) {
s = new MultiSlice();
}
// Case: non-empty string
else {
else { // FIXME: need to gracefully handle non-existent properties
throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) );
}
return s;
Expand Down
4 changes: 2 additions & 2 deletions fancy/lib/prop2slice.1d.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function prop2slice( target, property, strict ) {
// Case: slice
if ( ch === 'S' ) {
// Convert the string to a slice object:
s = str2slice( property );
s = str2slice( prop );
if ( s === null ) {
throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) );
}
Expand All @@ -81,7 +81,7 @@ function prop2slice( target, property, strict ) {
s = new MultiSlice( s );
}
// Case: subsequence string
else if ( prop.length > 0 ) {
else if ( prop.length > 0 ) { // FIXME: need to gracefully handle non-existent properties
shape = target.shape;
s = seq2multislice( prop, shape, true );
if ( s.code ) {
Expand Down
2 changes: 1 addition & 1 deletion fancy/lib/prop2slice.nd.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function prop2slice( target, property, strict ) {
// Case: array syntax (e.g., [ Slice(0,10,1), null, Slice(4,null,-1) ]) or Slice or integer or arbitrary string (where the latter three are not valid for >2d arrays)
else {
s = sargs2multislice( prop );
if ( s === null ) {
if ( s === null ) { // FIXME: need to gracefully handle non-existent properties
throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', property ) );
}
}
Expand Down
13 changes: 5 additions & 8 deletions fancy/lib/set_slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var complexDataType = require( '@stdlib/complex/dtype' );
var scalar2ndarray = require( './../../from-scalar' );
var format = require( '@stdlib/string/format' );
var errMessage = require( './error_message.js' );
var errConstructor = require( './error_constructor.js' );


// FUNCTIONS //
Expand Down Expand Up @@ -75,11 +74,10 @@ function options( dtype ) {
* @throws {TypeError} target array must have a supported data type
* @returns {boolean} boolean indicating whether assignment succeeded
*/
function setSlice( target, property, value, receiver, prop2slice ) { // eslint-disable-line stdlib/jsdoc-require-throws-tags
function setSlice( target, property, value, receiver, prop2slice ) {
var strict;
var vdt;
var dt;
var E;
var s;

if ( !isndarrayLike( value ) ) {
Expand All @@ -89,15 +87,15 @@ function setSlice( target, property, value, receiver, prop2slice ) { // eslint-d
if ( dt === 'generic' ) {
value = scalar2ndarray( value, options( dt ) );
}
// If the input value is real-valued number, we need to inspect the value to determine whether we can safely cast the value to the target array data type...
// If the input value is a real-valued number, we need to inspect the value to determine whether we can safely cast the value to the target array data type...
else if ( isNumber( value ) ) {
// If the target array has a floating-point data type, we can just go ahead and cast the input scalar to the target array data type...
// If the target array has a floating-point data type, we can just go ahead and cast the input scalar to the target array data type, as number literals are, by default, double-precision floating-point values and casting to lower-precision floating-point is allowed...
if ( isFloatingDataType( dt ) ) {
value = scalar2ndarray( value, options( dt ) );
}
// If the target array has an unsigned integer data type, then the assigned value must be a compatible nonnegative integer value...
else if ( isUnsignedIntegerDataType( dt ) ) {
vdt = minDataType( value );
vdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false`
if ( isSafeCast( vdt, dt ) ) {
value = scalar2ndarray( value, options( dt ) );
} else {
Expand Down Expand Up @@ -160,8 +158,7 @@ function setSlice( target, property, value, receiver, prop2slice ) { // eslint-d
sliceAssign( value, receiver, s, strict );
return true;
} catch ( err ) {
E = errConstructor( err );
throw new E( errMessage( err.message ) );
throw new err.constructor( errMessage( err.message ) );
}
}

Expand Down

0 comments on commit 59851e1

Please sign in to comment.