@@ -25,28 +25,28 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
25
25
< div class ='fl pad1y space-right2 '>
26
26
< span class ="strong "> 100% </ span >
27
27
< span class ="quiet "> Statements</ span >
28
- < span class ='fraction '> 332/332 </ span >
28
+ < span class ='fraction '> 373/373 </ span >
29
29
</ div >
30
30
31
31
32
32
< div class ='fl pad1y space-right2 '>
33
33
< span class ="strong "> 100% </ span >
34
34
< span class ="quiet "> Branches</ span >
35
- < span class ='fraction '> 28/28 </ span >
35
+ < span class ='fraction '> 34/34 </ span >
36
36
</ div >
37
37
38
38
39
39
< div class ='fl pad1y space-right2 '>
40
40
< span class ="strong "> 100% </ span >
41
41
< span class ="quiet "> Functions</ span >
42
- < span class ='fraction '> 8/8 </ span >
42
+ < span class ='fraction '> 10/10 </ span >
43
43
</ div >
44
44
45
45
46
46
< div class ='fl pad1y space-right2 '>
47
47
< span class ="strong "> 100% </ span >
48
48
< span class ="quiet "> Lines</ span >
49
- < span class ='fraction '> 332/332 </ span >
49
+ < span class ='fraction '> 373/373 </ span >
50
50
</ div >
51
51
52
52
@@ -395,7 +395,64 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
395
395
< a name ='L330 '> </ a > < a href ='#L330 '> 330</ a >
396
396
< a name ='L331 '> </ a > < a href ='#L331 '> 331</ a >
397
397
< a name ='L332 '> </ a > < a href ='#L332 '> 332</ a >
398
- < a name ='L333 '> </ a > < a href ='#L333 '> 333</ a > </ td > < td class ="line-coverage quiet "> < span class ="cline-any cline-yes "> 2x</ span >
398
+ < a name ='L333 '> </ a > < a href ='#L333 '> 333</ a >
399
+ < a name ='L334 '> </ a > < a href ='#L334 '> 334</ a >
400
+ < a name ='L335 '> </ a > < a href ='#L335 '> 335</ a >
401
+ < a name ='L336 '> </ a > < a href ='#L336 '> 336</ a >
402
+ < a name ='L337 '> </ a > < a href ='#L337 '> 337</ a >
403
+ < a name ='L338 '> </ a > < a href ='#L338 '> 338</ a >
404
+ < a name ='L339 '> </ a > < a href ='#L339 '> 339</ a >
405
+ < a name ='L340 '> </ a > < a href ='#L340 '> 340</ a >
406
+ < a name ='L341 '> </ a > < a href ='#L341 '> 341</ a >
407
+ < a name ='L342 '> </ a > < a href ='#L342 '> 342</ a >
408
+ < a name ='L343 '> </ a > < a href ='#L343 '> 343</ a >
409
+ < a name ='L344 '> </ a > < a href ='#L344 '> 344</ a >
410
+ < a name ='L345 '> </ a > < a href ='#L345 '> 345</ a >
411
+ < a name ='L346 '> </ a > < a href ='#L346 '> 346</ a >
412
+ < a name ='L347 '> </ a > < a href ='#L347 '> 347</ a >
413
+ < a name ='L348 '> </ a > < a href ='#L348 '> 348</ a >
414
+ < a name ='L349 '> </ a > < a href ='#L349 '> 349</ a >
415
+ < a name ='L350 '> </ a > < a href ='#L350 '> 350</ a >
416
+ < a name ='L351 '> </ a > < a href ='#L351 '> 351</ a >
417
+ < a name ='L352 '> </ a > < a href ='#L352 '> 352</ a >
418
+ < a name ='L353 '> </ a > < a href ='#L353 '> 353</ a >
419
+ < a name ='L354 '> </ a > < a href ='#L354 '> 354</ a >
420
+ < a name ='L355 '> </ a > < a href ='#L355 '> 355</ a >
421
+ < a name ='L356 '> </ a > < a href ='#L356 '> 356</ a >
422
+ < a name ='L357 '> </ a > < a href ='#L357 '> 357</ a >
423
+ < a name ='L358 '> </ a > < a href ='#L358 '> 358</ a >
424
+ < a name ='L359 '> </ a > < a href ='#L359 '> 359</ a >
425
+ < a name ='L360 '> </ a > < a href ='#L360 '> 360</ a >
426
+ < a name ='L361 '> </ a > < a href ='#L361 '> 361</ a >
427
+ < a name ='L362 '> </ a > < a href ='#L362 '> 362</ a >
428
+ < a name ='L363 '> </ a > < a href ='#L363 '> 363</ a >
429
+ < a name ='L364 '> </ a > < a href ='#L364 '> 364</ a >
430
+ < a name ='L365 '> </ a > < a href ='#L365 '> 365</ a >
431
+ < a name ='L366 '> </ a > < a href ='#L366 '> 366</ a >
432
+ < a name ='L367 '> </ a > < a href ='#L367 '> 367</ a >
433
+ < a name ='L368 '> </ a > < a href ='#L368 '> 368</ a >
434
+ < a name ='L369 '> </ a > < a href ='#L369 '> 369</ a >
435
+ < a name ='L370 '> </ a > < a href ='#L370 '> 370</ a >
436
+ < a name ='L371 '> </ a > < a href ='#L371 '> 371</ a >
437
+ < a name ='L372 '> </ a > < a href ='#L372 '> 372</ a >
438
+ < a name ='L373 '> </ a > < a href ='#L373 '> 373</ a >
439
+ < a name ='L374 '> </ a > < a href ='#L374 '> 374</ a > </ td > < td class ="line-coverage quiet "> < span class ="cline-any cline-yes "> 2x</ span >
440
+ < span class ="cline-any cline-yes "> 2x</ span >
441
+ < span class ="cline-any cline-yes "> 2x</ span >
442
+ < span class ="cline-any cline-yes "> 2x</ span >
443
+ < span class ="cline-any cline-yes "> 2x</ span >
444
+ < span class ="cline-any cline-yes "> 2x</ span >
445
+ < span class ="cline-any cline-yes "> 2x</ span >
446
+ < span class ="cline-any cline-yes "> 2x</ span >
447
+ < span class ="cline-any cline-yes "> 2x</ span >
448
+ < span class ="cline-any cline-yes "> 2x</ span >
449
+ < span class ="cline-any cline-yes "> 2x</ span >
450
+ < span class ="cline-any cline-yes "> 2x</ span >
451
+ < span class ="cline-any cline-yes "> 2x</ span >
452
+ < span class ="cline-any cline-yes "> 2x</ span >
453
+ < span class ="cline-any cline-yes "> 2x</ span >
454
+ < span class ="cline-any cline-yes "> 2x</ span >
455
+ < span class ="cline-any cline-yes "> 2x</ span >
399
456
< span class ="cline-any cline-yes "> 2x</ span >
400
457
< span class ="cline-any cline-yes "> 2x</ span >
401
458
< span class ="cline-any cline-yes "> 2x</ span >
@@ -684,6 +741,28 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
684
741
< span class ="cline-any cline-yes "> 2x</ span >
685
742
< span class ="cline-any cline-yes "> 2x</ span >
686
743
< span class ="cline-any cline-yes "> 2x</ span >
744
+ < span class ="cline-any cline-yes "> 18x</ span >
745
+ < span class ="cline-any cline-yes "> 18x</ span >
746
+ < span class ="cline-any cline-yes "> 18x</ span >
747
+ < span class ="cline-any cline-yes "> 2x</ span >
748
+ < span class ="cline-any cline-yes "> 2x</ span >
749
+ < span class ="cline-any cline-yes "> 2x</ span >
750
+ < span class ="cline-any cline-yes "> 2x</ span >
751
+ < span class ="cline-any cline-yes "> 2x</ span >
752
+ < span class ="cline-any cline-yes "> 2x</ span >
753
+ < span class ="cline-any cline-yes "> 2x</ span >
754
+ < span class ="cline-any cline-yes "> 2x</ span >
755
+ < span class ="cline-any cline-yes "> 22x</ span >
756
+ < span class ="cline-any cline-yes "> 22x</ span >
757
+ < span class ="cline-any cline-yes "> 22x</ span >
758
+ < span class ="cline-any cline-yes "> 2x</ span >
759
+ < span class ="cline-any cline-yes "> 2x</ span >
760
+ < span class ="cline-any cline-yes "> 2x</ span >
761
+ < span class ="cline-any cline-yes "> 2x</ span >
762
+ < span class ="cline-any cline-yes "> 2x</ span >
763
+ < span class ="cline-any cline-yes "> 2x</ span >
764
+ < span class ="cline-any cline-yes "> 2x</ span >
765
+ < span class ="cline-any cline-yes "> 2x</ span >
687
766
< span class ="cline-any cline-yes "> 2x</ span >
688
767
< span class ="cline-any cline-yes "> 2x</ span >
689
768
< span class ="cline-any cline-yes "> 2x</ span >
@@ -718,8 +797,11 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
718
797
< span class ="cline-any cline-yes "> 99x</ span >
719
798
< span class ="cline-any cline-yes "> 99x</ span >
720
799
< span class ="cline-any cline-yes "> 198x</ span >
721
- < span class ="cline-any cline-yes "> 198x</ span >
722
- < span class ="cline-any cline-yes "> 198x</ span >
800
+ < span class ="cline-any cline-yes "> 297x</ span >
801
+ < span class ="cline-any cline-yes "> 158x</ span >
802
+ < span class ="cline-any cline-yes "> 158x</ span >
803
+ < span class ="cline-any cline-yes "> 40x</ span >
804
+ < span class ="cline-any cline-yes "> 40x</ span >
723
805
< span class ="cline-any cline-yes "> 28x</ span >
724
806
< span class ="cline-any cline-yes "> 440x</ span >
725
807
< span class ="cline-any cline-yes "> 2x</ span >
@@ -764,6 +846,7 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
764
846
var isBooleanIndexDataType = require( '@stdlib/ndarray/base/assert/is-boolean-index-data-type' );
765
847
var isMaskIndexDataType = require( '@stdlib/ndarray/base/assert/is-mask-index-data-type' );
766
848
var isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' );
849
+ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
767
850
var promoteDataTypes = require( '@stdlib/ndarray/base/promote-dtypes' );
768
851
var defaults = require( '@stdlib/ndarray/defaults' );
769
852
var join = require( '@stdlib/array/base/join' );
@@ -777,6 +860,7 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
777
860
var DEFAULT_SIGNED_INTEGER_DTYPE = defaults.get( 'dtypes.signed_integer' );
778
861
var DEFAULT_UNSIGNED_INTEGER_DTYPE = defaults.get( 'dtypes.unsigned_integer' );
779
862
var DEFAULT_REAL_FLOATING_POINT_DTYPE = defaults.get( 'dtypes.real_floating_point' );
863
+ var DEFAULT_COMPLEX_FLOATING_POINT_DTYPE = defaults.get( 'dtypes.complex_floating_point' );
780
864
781
865
// Table where, for each respective policy, the value is a function which applies the policy to an input data type...
782
866
var POLICY_TABLE1 = {
@@ -800,19 +884,19 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
800
884
],
801
885
'real_floating_point': [
802
886
isRealFloatingPointDataType,
803
- DEFAULT_REAL_FLOATING_POINT_DTYPE
887
+ resolveDefaultRealFloatingPoint
804
888
],
805
889
'real_floating_point_and_generic': [
806
890
wrap( isRealFloatingPointDataType ),
807
- DEFAULT_REAL_FLOATING_POINT_DTYPE
891
+ resolveDefaultRealFloatingPoint
808
892
],
809
893
'complex_floating_point': [
810
894
isComplexFloatingPointDataType,
811
- defaults.get( 'dtypes.complex_floating_point' )
895
+ resolveDefaultComplexFloatingPoint
812
896
],
813
897
'complex_floating_point_and_generic': [
814
898
wrap( isComplexFloatingPointDataType ),
815
- defaults.get( 'dtypes.complex_floating_point' )
899
+ resolveDefaultComplexFloatingPoint
816
900
],
817
901
818
902
// Integer policies...
@@ -898,6 +982,20 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
898
982
]
899
983
};
900
984
985
+ // Table mapping complex-valued floating-point data types to real-valued floating-point data types having the same precision:
986
+ var COMPLEX2FLOAT = {
987
+ 'complex128': 'float64',
988
+ 'complex64': 'float32',
989
+ 'complex32': 'float16'
990
+ };
991
+
992
+ // Table mapping real-valued floating-point data types to complex-valued floating-point data types having the same precision:
993
+ var FLOAT2COMPLEX = {
994
+ 'float64': 'complex128',
995
+ 'float32': 'complex64',
996
+ 'float16': 'complex32'
997
+ };
998
+
901
999
902
1000
// FUNCTIONS //
903
1001
@@ -1009,6 +1107,28 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
1009
1107
return DEFAULT_REAL_FLOATING_POINT_DTYPE;
1010
1108
}
1011
1109
1110
+ /**
1111
+ * Resolves a default real-valued floating-point data type which preserves floating-point precision.
1112
+ *
1113
+ * @private
1114
+ * @param {string} dtype - input ndarray data type
1115
+ * @returns {string} output ndarray data type
1116
+ */
1117
+ function resolveDefaultRealFloatingPoint( dtype ) {
1118
+ return COMPLEX2FLOAT[ dtype ] || DEFAULT_REAL_FLOATING_POINT_DTYPE;
1119
+ }
1120
+
1121
+ /**
1122
+ * Resolves a default complex-valued floating-point data type which preserves floating-point precision.
1123
+ *
1124
+ * @private
1125
+ * @param {string} dtype - input ndarray data type
1126
+ * @returns {string} output ndarray data type
1127
+ */
1128
+ function resolveDefaultComplexFloatingPoint( dtype ) {
1129
+ return FLOAT2COMPLEX[ dtype ] || DEFAULT_COMPLEX_FLOATING_POINT_DTYPE;
1130
+ }
1131
+
1012
1132
1013
1133
// MAIN //
1014
1134
@@ -1049,8 +1169,11 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
1049
1169
// If so, we can just return the promoted data type:
1050
1170
return dt;
1051
1171
}
1052
- // Otherwise, we need to fallback to a default data type belonging to that "kind":
1053
- return p[ 1 ];
1172
+ // Otherwise, we need to fallback to a default data type belonging to that "kind"...
1173
+ if ( isString( p[ 1 ] ) ) {
1174
+ return p[ 1 ];
1175
+ }
1176
+ return p[ 1 ]( dt );
1054
1177
}
1055
1178
throw new TypeError( format( 'invalid argument. Second argument must be a supported data type policy. Value: `%s`.', policy ) );
1056
1179
}
@@ -1066,7 +1189,7 @@ <h1><a href="../../../../index.html">All files</a> / <a href="index.html">ndarra
1066
1189
< div class ='footer quiet pad2 space-top1 center small '>
1067
1190
Code coverage generated by
1068
1191
< a href ="https://istanbul.js.org/ " target ="_blank " rel ="noopener noreferrer "> istanbul</ a >
1069
- at 2025-05-10T11:02:22.696Z
1192
+ at 2025-09-13T09:08:12.367Z
1070
1193
</ div >
1071
1194
< script src ="../../../../prettify.js "> </ script >
1072
1195
< script >
0 commit comments