Skip to content

Commit d6fb821

Browse files
committed
NPTypeCode: Removed NPTypeCode.NDArray.
1 parent 51e510e commit d6fb821

File tree

8 files changed

+2
-55
lines changed

8 files changed

+2
-55
lines changed

src/NumSharp.Core/Backends/NPTypeCode.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,48 @@ namespace NumSharp
1515
public enum NPTypeCode
1616
{
1717
/// <summary>A null reference.</summary>
18-
/// <returns></returns>
1918
Empty = 0,
2019

2120
/// <summary>A simple type representing Boolean values of true or false.</summary>
22-
/// <returns></returns>
2321
Boolean = 3,
2422

2523
/// <summary>An integral type representing unsigned 16-bit integers with values between 0 and 65535. The set of possible values for the <see cref="F:System.TypeCode.Char"></see> type corresponds to the Unicode character set.</summary>
26-
/// <returns></returns>
2724
Char = 4,
2825

2926
/// <summary>An integral type representing unsigned 8-bit integers with values between 0 and 255.</summary>
30-
/// <returns></returns>
3127
Byte = 6,
3228

3329
/// <summary>An integral type representing signed 16-bit integers with values between -32768 and 32767.</summary>
34-
/// <returns></returns>
3530
Int16 = 7,
3631

3732
/// <summary>An integral type representing unsigned 16-bit integers with values between 0 and 65535.</summary>
38-
/// <returns></returns>
3933
UInt16 = 8,
4034

4135
/// <summary>An integral type representing signed 32-bit integers with values between -2147483648 and 2147483647.</summary>
42-
/// <returns></returns>
4336
Int32 = 9,
4437

4538
/// <summary>An integral type representing unsigned 32-bit integers with values between 0 and 4294967295.</summary>
46-
/// <returns></returns>
4739
UInt32 = 10, // 0x0000000A
4840

4941
/// <summary>An integral type representing signed 64-bit integers with values between -9223372036854775808 and 9223372036854775807.</summary>
50-
/// <returns></returns>
5142
Int64 = 11, // 0x0000000B
5243

5344
/// <summary>An integral type representing unsigned 64-bit integers with values between 0 and 18446744073709551615.</summary>
54-
/// <returns></returns>
5545
UInt64 = 12, // 0x0000000C
5646

5747
/// <summary>A floating point type representing values ranging from approximately 1.5 x 10 -45 to 3.4 x 10 38 with a precision of 7 digits.</summary>
58-
/// <returns></returns>
5948
Single = 13, // 0x0000000D
6049

6150
/// <summary>A floating point type representing values ranging from approximately 5.0 x 10 -324 to 1.7 x 10 308 with a precision of 15-16 digits.</summary>
62-
/// <returns></returns>
6351
Double = 14, // 0x0000000E
6452

6553
/// <summary>A simple type representing values ranging from 1.0 x 10 -28 to approximately 7.9 x 10 28 with 28-29 significant digits.</summary>
66-
/// <returns></returns>
6754
Decimal = 15, // 0x0000000F
6855

6956
/// <summary>A sealed class type representing Unicode character strings.</summary>
70-
/// <returns></returns>
7157
String = 18, // 0x00000012
7258

7359
Complex = 128, //0x00000080
74-
75-
NDArray = 129, //0x00000081
7660
}
7761

7862
public static class NPTypeCodeExtensions
@@ -101,11 +85,6 @@ public static NPTypeCode GetTypeCode(this Type type)
10185
var tc = Type.GetTypeCode(type);
10286
if (tc == TypeCode.Object)
10387
{
104-
if (type == typeof(NDArray))
105-
{
106-
return NPTypeCode.NDArray;
107-
}
108-
10988
if (type == typeof(Complex))
11089
{
11190
return NPTypeCode.Complex;
@@ -152,7 +131,6 @@ public static Type AsType(this NPTypeCode typeCode)
152131
default:
153132
throw new NotSupportedException();
154133
#else
155-
case NPTypeCode.NDArray: return typeof(NDArray);
156134
case NPTypeCode.Complex: return typeof(Complex);
157135
case NPTypeCode.Boolean: return typeof(bool);
158136
case NPTypeCode.Byte: return typeof(byte);
@@ -202,7 +180,6 @@ public static int SizeOf(this NPTypeCode typeCode)
202180
default:
203181
throw new NotSupportedException();
204182
#else
205-
case NPTypeCode.NDArray: return IntPtr.Size;
206183
case NPTypeCode.Complex: return InfoOf<Complex>.Size;
207184
case NPTypeCode.Boolean: return 1;
208185
case NPTypeCode.Byte: return 1;
@@ -239,7 +216,6 @@ public static bool IsRealNumber(this NPTypeCode typeCode)
239216
default:
240217
throw new NotSupportedException();
241218
#else
242-
case NPTypeCode.NDArray: return false;
243219
case NPTypeCode.Complex: return true;
244220
case NPTypeCode.Boolean: return false;
245221
case NPTypeCode.Byte: return false;
@@ -276,7 +252,6 @@ public static bool IsUnsigned(this NPTypeCode typeCode)
276252
default:
277253
throw new NotSupportedException();
278254
#else
279-
case NPTypeCode.NDArray: return false;
280255
case NPTypeCode.Complex: return false;
281256
case NPTypeCode.Boolean: return true;
282257
case NPTypeCode.Byte: return true;
@@ -313,7 +288,6 @@ public static bool IsSigned(this NPTypeCode typeCode)
313288
default:
314289
throw new NotSupportedException();
315290
#else
316-
case NPTypeCode.NDArray: return false;
317291
case NPTypeCode.Complex: return false;
318292
case NPTypeCode.Boolean: return false;
319293
case NPTypeCode.Byte: return false;
@@ -370,7 +344,6 @@ internal static int GetGroup(this NPTypeCode typeCode)
370344
case NPTypeCode.Decimal: return 4;
371345

372346
case NPTypeCode.Complex: return 10;
373-
case NPTypeCode.NDArray: return 100;
374347
default:
375348
throw new NotSupportedException();
376349
#endif
@@ -411,7 +384,6 @@ internal static int GetPriority(this NPTypeCode typeCode)
411384
case NPTypeCode.Decimal: return 5 * 10 * 32;
412385

413386
case NPTypeCode.Complex: return 5000;
414-
case NPTypeCode.NDArray: return 10000;
415387
default:
416388
throw new NotSupportedException();
417389
#endif
@@ -527,8 +499,6 @@ internal static NPY_TYPECHAR ToTYPECHAR(this NPTypeCode typeCode)
527499
return NPY_TYPECHAR.NPY_STRINGLTR;
528500
case NPTypeCode.Complex:
529501
return NPY_TYPECHAR.NPY_COMPLEXLTR;
530-
case NPTypeCode.NDArray:
531-
return NPY_TYPECHAR.NPY_OBJECTLTR;
532502
default:
533503
throw new ArgumentOutOfRangeException(nameof(typeCode), typeCode, null);
534504
}
@@ -594,8 +564,6 @@ internal static string AsNumpyDtypeName(this NPTypeCode typeCode)
594564
return "string";
595565
case NPTypeCode.Complex:
596566
return "complex64";
597-
case NPTypeCode.NDArray:
598-
return "object";
599567
default:
600568
throw new ArgumentOutOfRangeException(nameof(typeCode), typeCode, null);
601569
}

src/NumSharp.Core/Backends/Unmanaged/UnmanagedStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public int DTypeSize
7070
{
7171
get
7272
{
73-
if (_typecode == NPTypeCode.NDArray || _typecode == NPTypeCode.String)
73+
if (_typecode == NPTypeCode.String)
7474
{
7575
return IntPtr.Size;
7676
}

src/NumSharp.Core/Creation/np.dtype.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class DType
1212
{
1313
protected internal static readonly Dictionary<NPTypeCode, char> _kind_list_map = new Dictionary<NPTypeCode, char>()
1414
{
15-
{NPTypeCode.NDArray, 'O'},
1615
{NPTypeCode.Complex, 'c'},
1716
{NPTypeCode.Boolean, '?'},
1817
{NPTypeCode.Byte, 'b'},
@@ -185,7 +184,6 @@ public static DType dtype(string dtype)
185184
{
186185
switch (code)
187186
{
188-
case NPTypeCode.NDArray: return new DType(typeof(IntPtr)); //todo! ??
189187
#if _REGEN
190188
%foreach all_dtypes%
191189
case NPTypeCode.#1: return new DType(typeof(#1));

src/NumSharp.Core/Creation/np.ones.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ public static NDArray ones(Shape shape, NPTypeCode typeCode)
7878
case NPTypeCode.Complex:
7979
one = new Complex(1d, 0d);
8080
break;
81-
case NPTypeCode.NDArray:
82-
one = NDArray.Scalar(1, np.int32);
83-
break;
8481
case NPTypeCode.String:
8582
one = "1";
8683
break;

src/NumSharp.Core/Logic/np.find_common_type.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ static np()
451451
NPTypeCode.Complex, //Complex64
452452
NPTypeCode.Complex, //Complex128
453453
//NPTypeCode.Complex, //Complex128
454-
NPTypeCode.NDArray,
455454
NPTypeCode.Single,
456455
};
457456
// @formatter:off — disable formatter after this line
@@ -479,7 +478,6 @@ private static readonly (NPTypeCode Type, int Priority)[] powerPriorities =
479478
(NPTypeCode.Complex, NPTypeCode.Complex.GetPriority()), //Complex64
480479
(NPTypeCode.Complex, NPTypeCode.Complex.GetPriority()), //Complex128
481480
//NPTypeCode.Complex, //Complex128
482-
(NPTypeCode.NDArray, NPTypeCode.NDArray.GetPriority()),
483481
(NPTypeCode.Single, NPTypeCode.Single.GetPriority()),
484482
};
485483

src/NumSharp.Core/NumSharp.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393

9494
<ItemGroup>
9595
<None Remove="NumSharp.Core.csproj.DotSettings" />
96+
<None Remove="Open.snk" />
9697
<None Remove="Operations\NdArray.ElementsWise.tt" />
9798
<None Include="..\..\LICENSE">
9899
<Pack>True</Pack>

src/NumSharp.Core/Utilities/Arrays.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,6 @@ public static Array Create(NPTypeCode typeCode, int length)
427427
default:
428428
throw new NotImplementedException();
429429
#else
430-
431-
case NPTypeCode.NDArray:
432-
{
433-
return new NDArray[length];
434-
}
435-
436430
case NPTypeCode.Complex:
437431
{
438432
return new Complex[length];
@@ -529,12 +523,6 @@ public static Array Wrap(NPTypeCode typeCode, object value)
529523
default:
530524
throw new NotImplementedException();
531525
#else
532-
533-
case NPTypeCode.NDArray:
534-
{
535-
return new NDArray[1] {(NDArray)value};
536-
}
537-
538526
case NPTypeCode.Complex:
539527
{
540528
return new Complex[1] {(Complex)value};

src/NumSharp.Core/Utilities/InfoOf.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ static InfoOf()
3131

3232
switch (NPTypeCode)
3333
{
34-
case NPTypeCode.NDArray:
35-
Size = IntPtr.Size;
36-
break;
3734
case NPTypeCode.Boolean:
3835
Size = 1;
3936
break;

0 commit comments

Comments
 (0)