Skip to content

Commit 80213ee

Browse files
committed
Extend to ndarray.ravel
1 parent 7495ab2 commit 80213ee

2 files changed

Lines changed: 56 additions & 40 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace NumSharp.Core
7+
{
8+
public partial class NDArray
9+
{
10+
public NDArray delete(IEnumerable delete)
11+
{
12+
var np = new NumPy();
13+
14+
var sysArr = this.Storage.GetData();
15+
16+
NDArray res = null;
17+
18+
switch( sysArr)
19+
{
20+
case double[] castedSysArr :
21+
{
22+
var castedDelete = delete as double[];
23+
24+
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
25+
26+
break;
27+
}
28+
case float[] castedSysArr :
29+
{
30+
var castedDelete = delete as float[];
31+
32+
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
33+
34+
break;
35+
}
36+
case int[] castedSysArr :
37+
{
38+
var castedDelete = delete as int[];
39+
40+
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
41+
42+
break;
43+
}
44+
default :
45+
{
46+
throw new IncorrectTypeException();
47+
}
48+
}
49+
50+
return res;
51+
}
52+
}
53+
}

src/NumSharp.Core/Manipulation/NdArray.delete.cs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,10 @@ namespace NumSharp.Core
77
{
88
public partial class NDArray
99
{
10-
public NDArray delete(IEnumerable delete)
10+
public NDArray ravel()
1111
{
12-
var np = new NumPy();
13-
14-
var sysArr = this.Storage.GetData();
15-
16-
NDArray res = null;
17-
18-
switch( sysArr)
19-
{
20-
case double[] castedSysArr :
21-
{
22-
var castedDelete = delete as double[];
23-
24-
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
25-
26-
break;
27-
}
28-
case float[] castedSysArr :
29-
{
30-
var castedDelete = delete as float[];
31-
32-
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
33-
34-
break;
35-
}
36-
case int[] castedSysArr :
37-
{
38-
var castedDelete = delete as int[];
39-
40-
res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
41-
42-
break;
43-
}
44-
default :
45-
{
46-
throw new IncorrectTypeException();
47-
}
48-
}
49-
50-
return res;
12+
Storage.Shape = new Shape(shape.Size);
13+
return this;
5114
}
5215
}
5316
}

0 commit comments

Comments
 (0)