@@ -9,31 +9,32 @@ namespace NumSharp.Core
99{
1010 public static partial class np
1111 {
12- public static NDArray asarray ( double [ ] data , int ndim = 1 )
12+ public static NDArray asarray ( string data )
1313 {
14- var nd = new NDArray ( typeof ( double ) , data . Length ) ;
15- nd . Storage . SetData ( data ) ;
14+ var nd = new NDArray ( typeof ( string ) , new int [ 0 ] ) ;
15+ nd . Storage . SetData ( new string [ ] { data } ) ;
1616 return nd ;
1717 }
1818
19- public static NDArray asarray ( float data )
19+ public static NDArray asarray < T > ( T data ) where T : struct
2020 {
21- return new NDArray ( new float [ ] { data } ) ;
21+ var nd = new NDArray ( typeof ( T ) , new int [ 0 ] ) ;
22+ nd . Storage . SetData ( new T [ ] { data } ) ;
23+ return nd ;
2224 }
2325
24- public static NDArray asarray ( float [ ] data , int ndim = 1 )
26+ public static NDArray asarray ( string [ ] data , int ndim = 1 )
2527 {
26- var nd = new NDArray ( typeof ( float ) , data . Length ) ;
28+ var nd = new NDArray ( typeof ( string ) , data . Length ) ;
2729 nd . Storage . SetData ( data ) ;
2830 return nd ;
2931 }
30- /*
31- public static NDArray asarray(matrix mx , int ndim = 1)
32+
33+ public static NDArray asarray < T > ( T [ ] data , int ndim = 1 ) where T : struct
3234 {
33- var nd = new NDArray(mx.dtype, mx.shape );
34- nd.Storage = mx.Storage ;
35+ var nd = new NDArray ( typeof ( T ) , data . Length ) ;
36+ nd . Storage . SetData ( data ) ;
3537 return nd ;
3638 }
37- */
3839 }
3940}
0 commit comments