Skip to content

Commit

Permalink
Fixed reshape handling of shape argument when it's an ndarray.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason McCampbell (Enthought, Inc) committed Apr 22, 2011
1 parent b42256f commit b1f7d19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions numpy/NumpyDotNet/NpyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ internal static IntPtr IntpConverter(object arg) {
}
}

internal static IntPtr[] IntpListConverter(IList<object> args) {
IntPtr[] result = new IntPtr[args.Count];
internal static IntPtr[] IntpListConverter(IEnumerable<object> args) {
IntPtr[] result = new IntPtr[args.Count()];
int i=0;
foreach (object arg in args) {
result[i++] = IntpConverter(arg);
Expand Down
5 changes: 3 additions & 2 deletions numpy/NumpyDotNet/ndarray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,11 +1649,12 @@ public ndarray reshape([ParamDictionary] IDictionary<object,object> kwds, params
// TODO: Add NpyArray_View call for (None) case. (Why?)
if (args == null) {
newshape = new IntPtr[0];
} else if (args.Length == 1 && args[0] is IList<object>) {
newshape = NpyUtil_ArgProcessing.IntpListConverter((IList<object>)args[0]);
} else if (args.Length == 1 && (args[0] is IList<object> || args[0] is ndarray)) {
newshape = NpyUtil_ArgProcessing.IntpListConverter((IEnumerable<object>)args[0]);
} else {
newshape = NpyUtil_ArgProcessing.IntpListConverter(args);
}
Console.WriteLine("Calling NewShape with {0}, {1}", newshape, order);
return NpyCoreApi.Newshape(this, newshape, order);
}

Expand Down

0 comments on commit b1f7d19

Please sign in to comment.