forked from SciSharp/Numpy.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumPy.io.gen.cs
More file actions
1324 lines (1301 loc) · 59.3 KB
/
NumPy.io.gen.cs
File metadata and controls
1324 lines (1301 loc) · 59.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2019 by the SciSharp Team
// Code generated by CodeMinion: https://github.com/SciSharp/CodeMinion
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Python.Runtime;
using Numpy.Models;
namespace Numpy
{
public partial class NumPy
{
/// <summary>
/// Load arrays or pickled objects from .npy, .npz or pickled files.<br></br>
///
/// Notes
/// </summary>
/// <param name="file">
/// The file to read.<br></br>
/// File-like objects must support the
/// seek() and read() methods.<br></br>
/// Pickled files require that the
/// file-like object support the readline() method as well.
/// </param>
/// <param name="mmap_mode">
/// If not None, then memory-map the file, using the given mode (see
/// numpy.memmap for a detailed description of the modes).<br></br>
/// A
/// memory-mapped array is kept on disk.<br></br>
/// However, it can be accessed
/// and sliced like any ndarray.<br></br>
/// Memory mapping is especially useful
/// for accessing small fragments of large files without reading the
/// entire file into memory.
/// </param>
/// <param name="allow_pickle">
/// Allow loading pickled object arrays stored in npy files.<br></br>
/// Reasons for
/// disallowing pickles include security, as loading pickled data can
/// execute arbitrary code.<br></br>
/// If pickles are disallowed, loading object
/// arrays will fail.<br></br>
///
/// Default: True
/// </param>
/// <param name="fix_imports">
/// Only useful when loading Python 2 generated pickled files on Python 3,
/// which includes npy/npz files containing object arrays.<br></br>
/// If fix_imports
/// is True, pickle will try to map the old Python 2 names to the new names
/// used in Python 3.
/// </param>
/// <param name="encoding">
/// What encoding to use when reading Python 2 strings.<br></br>
/// Only useful when
/// loading Python 2 generated pickled files in Python 3, which includes
/// npy/npz files containing object arrays.<br></br>
/// Values other than ‘latin1’,
/// ‘ASCII’, and ‘bytes’ are not allowed, as they can corrupt numerical
/// data.<br></br>
/// Default: ‘ASCII’
/// </param>
/// <returns>
/// Data stored in the file.<br></br>
/// For .npz files, the returned instance
/// of NpzFile class must be closed to avoid leaking file descriptors.
/// </returns>
public NDarray load(string file, MemMapMode mmap_mode = null, bool? allow_pickle = true, bool? fix_imports = true, string encoding = "ASCII")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
file,
});
var kwargs=new PyDict();
if (mmap_mode!=null) kwargs["mmap_mode"]=ToPython(mmap_mode);
if (allow_pickle!=true) kwargs["allow_pickle"]=ToPython(allow_pickle);
if (fix_imports!=true) kwargs["fix_imports"]=ToPython(fix_imports);
if (encoding!="ASCII") kwargs["encoding"]=ToPython(encoding);
dynamic py = __self__.InvokeMethod("load", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Save an array to a binary file in NumPy .npy format.<br></br>
///
/// Notes
///
/// For a description of the .npy format, see numpy.lib.format.
/// </summary>
/// <param name="file">
/// File or filename to which the data is saved.<br></br>
/// If file is a file-object,
/// then the filename is unchanged.<br></br>
/// If file is a string or Path, a .npy
/// extension will be appended to the file name if it does not already
/// have one.
/// </param>
/// <param name="arr">
/// Array data to be saved.
/// </param>
/// <param name="allow_pickle">
/// Allow saving object arrays using Python pickles.<br></br>
/// Reasons for disallowing
/// pickles include security (loading pickled data can execute arbitrary
/// code) and portability (pickled objects may not be loadable on different
/// Python installations, for example if the stored objects require libraries
/// that are not available, and not all pickled data is compatible between
/// Python 2 and Python 3).<br></br>
///
/// Default: True
/// </param>
/// <param name="fix_imports">
/// Only useful in forcing objects in object arrays on Python 3 to be
/// pickled in a Python 2 compatible way.<br></br>
/// If fix_imports is True, pickle
/// will try to map the new Python 3 names to the old module names used in
/// Python 2, so that the pickle data stream is readable with Python 2.
/// </param>
public void save(string file, NDarray arr, bool? allow_pickle = true, bool? fix_imports = true)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
file,
arr,
});
var kwargs=new PyDict();
if (allow_pickle!=true) kwargs["allow_pickle"]=ToPython(allow_pickle);
if (fix_imports!=true) kwargs["fix_imports"]=ToPython(fix_imports);
dynamic py = __self__.InvokeMethod("save", pyargs, kwargs);
}
/// <summary>
/// Save several arrays into a single file in uncompressed .npz format.<br></br>
///
/// If arguments are passed in with no keywords, the corresponding variable
/// names, in the .npz file, are ‘arr_0’, ‘arr_1’, etc.<br></br>
/// If keyword
/// arguments are given, the corresponding variable names, in the .npz
/// file will match the keyword names.<br></br>
///
/// Notes
///
/// The .npz file format is a zipped archive of files named after the
/// variables they contain.<br></br>
/// The archive is not compressed and each file
/// in the archive contains one variable in .npy format.<br></br>
/// For a
/// description of the .npy format, see numpy.lib.format.<br></br>
///
/// When opening the saved .npz file with load a NpzFile object is
/// returned.<br></br>
/// This is a dictionary-like object which can be queried for
/// its list of arrays (with the .files attribute), and for the arrays
/// themselves.
/// </summary>
/// <param name="file">
/// Either the file name (string) or an open file (file-like object)
/// where the data will be saved.<br></br>
/// If file is a string or a Path, the
/// .npz extension will be appended to the file name if it is not
/// already there.
/// </param>
/// <param name="args">
/// Arrays to save to the file.<br></br>
/// Since it is not possible for Python to
/// know the names of the arrays outside savez, the arrays will be saved
/// with names “arr_0”, “arr_1”, and so on.<br></br>
/// These arguments can be any
/// expression.
/// </param>
/// <param name="kwds">
/// Arrays to save to the file.<br></br>
/// Arrays will be saved in the file with the
/// keyword names.
/// </param>
public void savez(string file, NDarray[] args = null, Dictionary<string, NDarray> kwds = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
file,
});
var kwargs=new PyDict();
if (args!=null) kwargs["args"]=ToPython(args);
if (kwds!=null) kwargs["kwds"]=ToPython(kwds);
dynamic py = __self__.InvokeMethod("savez", pyargs, kwargs);
}
/// <summary>
/// Save several arrays into a single file in compressed .npz format.<br></br>
///
/// If keyword arguments are given, then filenames are taken from the keywords.<br></br>
///
/// If arguments are passed in with no keywords, then stored file names are
/// arr_0, arr_1, etc.<br></br>
///
/// Notes
///
/// The .npz file format is a zipped archive of files named after the
/// variables they contain.<br></br>
/// The archive is compressed with
/// zipfile.ZIP_DEFLATED and each file in the archive contains one variable
/// in .npy format.<br></br>
/// For a description of the .npy format, see
/// numpy.lib.format.<br></br>
///
/// When opening the saved .npz file with load a NpzFile object is
/// returned.<br></br>
/// This is a dictionary-like object which can be queried for
/// its list of arrays (with the .files attribute), and for the arrays
/// themselves.
/// </summary>
/// <param name="file">
/// Either the file name (string) or an open file (file-like object)
/// where the data will be saved.<br></br>
/// If file is a string or a Path, the
/// .npz extension will be appended to the file name if it is not
/// already there.
/// </param>
/// <param name="args">
/// Arrays to save to the file.<br></br>
/// Since it is not possible for Python to
/// know the names of the arrays outside savez, the arrays will be saved
/// with names “arr_0”, “arr_1”, and so on.<br></br>
/// These arguments can be any
/// expression.
/// </param>
/// <param name="kwds">
/// Arrays to save to the file.<br></br>
/// Arrays will be saved in the file with the
/// keyword names.
/// </param>
public void savez_compressed(string file, NDarray[] args = null, Dictionary<string, NDarray> kwds = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
file,
});
var kwargs=new PyDict();
if (args!=null) kwargs["args"]=ToPython(args);
if (kwds!=null) kwargs["kwds"]=ToPython(kwds);
dynamic py = __self__.InvokeMethod("savez_compressed", pyargs, kwargs);
}
/// <summary>
/// Save an array to a text file.<br></br>
///
/// Notes
///
/// Further explanation of the fmt parameter
/// (%[flag]width[.precision]specifier):
///
/// This explanation of fmt is not complete, for an exhaustive
/// specification see [1].<br></br>
///
/// References
/// </summary>
/// <param name="fname">
/// If the filename ends in .gz, the file is automatically saved in
/// compressed gzip format.<br></br>
/// loadtxt understands gzipped files
/// transparently.
/// </param>
/// <param name="X">
/// Data to be saved to a text file.
/// </param>
/// <param name="fmt">
/// A single format (%10.5f), a sequence of formats, or a
/// multi-format string, e.g.<br></br>
/// ‘Iteration %d – %10.5f’, in which
/// case delimiter is ignored.<br></br>
/// For complex X, the legal options
/// for fmt are:
/// </param>
/// <param name="delimiter">
/// String or character separating columns.
/// </param>
/// <param name="newline">
/// String or character separating lines.
/// </param>
/// <param name="header">
/// String that will be written at the beginning of the file.
/// </param>
/// <param name="footer">
/// String that will be written at the end of the file.
/// </param>
/// <param name="comments">
/// String that will be prepended to the header and footer strings,
/// to mark them as comments.<br></br>
/// Default: ‘# ‘, as expected by e.g.<br></br>
///
/// numpy.loadtxt.
/// </param>
/// <param name="encoding">
/// Encoding used to encode the outputfile.<br></br>
/// Does not apply to output
/// streams.<br></br>
/// If the encoding is something other than ‘bytes’ or ‘latin1’
/// you will not be able to load the file in NumPy versions < 1.14. Default
/// is ‘latin1’.
/// </param>
public void savetxt(string fname, NDarray X, string[] fmt = null, string delimiter = " ", string newline = "\n", string header = "", string footer = "", string comments = null, string encoding = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
fname,
X,
});
var kwargs=new PyDict();
if (fmt!=null) kwargs["fmt"]=ToPython(fmt);
if (delimiter!=" ") kwargs["delimiter"]=ToPython(delimiter);
if (newline!="\n") kwargs["newline"]=ToPython(newline);
if (header!="") kwargs["header"]=ToPython(header);
if (footer!="") kwargs["footer"]=ToPython(footer);
if (comments!=null) kwargs["comments"]=ToPython(comments);
if (encoding!=null) kwargs["encoding"]=ToPython(encoding);
dynamic py = __self__.InvokeMethod("savetxt", pyargs, kwargs);
}
/*
/// <summary>
/// Load data from a text file, with missing values handled as specified.<br></br>
///
/// Each line past the first skip_header lines is split at the delimiter
/// character, and characters following the comments character are discarded.<br></br>
///
/// Notes
///
/// References
/// </summary>
/// <param name="fname">
/// File, filename, list, or generator to read.<br></br>
/// If the filename
/// extension is gz or bz2, the file is first decompressed.<br></br>
/// Note
/// that generators must return byte strings in Python 3k.<br></br>
/// The strings
/// in a list or produced by a generator are treated as lines.
/// </param>
/// <param name="dtype">
/// Data type of the resulting array.<br></br>
///
/// If None, the dtypes will be determined by the contents of each
/// column, individually.
/// </param>
/// <param name="comments">
/// The character used to indicate the start of a comment.<br></br>
///
/// All the characters occurring on a line after a comment are discarded
/// </param>
/// <param name="delimiter">
/// The string used to separate values.<br></br>
/// By default, any consecutive
/// whitespaces act as delimiter.<br></br>
/// An integer or sequence of integers
/// can also be provided as width(s) of each field.
/// </param>
/// <param name="skiprows">
/// skiprows was removed in numpy 1.10. Please use skip_header instead.
/// </param>
/// <param name="skip_header">
/// The number of lines to skip at the beginning of the file.
/// </param>
/// <param name="skip_footer">
/// The number of lines to skip at the end of the file.
/// </param>
/// <param name="converters">
/// The set of functions that convert the data of a column to a value.<br></br>
///
/// The converters can also be used to provide a default value
/// for missing data: converters = {3: lambda s: float(s or 0)}.
/// </param>
/// <param name="missing">
/// missing was removed in numpy 1.10. Please use missing_values
/// instead.
/// </param>
/// <param name="missing_values">
/// The set of strings corresponding to missing data.
/// </param>
/// <param name="filling_values">
/// The set of values to be used as default when the data are missing.
/// </param>
/// <param name="usecols">
/// Which columns to read, with 0 being the first.<br></br>
/// For example,
/// usecols = (1, 4, 5) will extract the 2nd, 5th and 6th columns.
/// </param>
/// <param name="names">
/// If names is True, the field names are read from the first line after
/// the first skip_header lines.<br></br>
/// This line can optionally be proceeded
/// by a comment delimiter.<br></br>
/// If names is a sequence or a single-string of
/// comma-separated names, the names will be used to define the field names
/// in a structured dtype.<br></br>
/// If names is None, the names of the dtype
/// fields will be used, if any.
/// </param>
/// <param name="excludelist">
/// A list of names to exclude.<br></br>
/// This list is appended to the default list
/// [‘return’,’file’,’print’].<br></br>
/// Excluded names are appended an underscore:
/// for example, file would become file_.
/// </param>
/// <param name="deletechars">
/// A string combining invalid characters that must be deleted from the
/// names.
/// </param>
/// <param name="defaultfmt">
/// A format used to define default field names, such as “f%i” or “f_%02i”.
/// </param>
/// <param name="autostrip">
/// Whether to automatically strip white spaces from the variables.
/// </param>
/// <param name="replace_space">
/// Character(s) used in replacement of white spaces in the variables
/// names.<br></br>
/// By default, use a ‘_’.
/// </param>
/// <param name="case_sensitive">
/// If True, field names are case sensitive.<br></br>
///
/// If False or ‘upper’, field names are converted to upper case.<br></br>
///
/// If ‘lower’, field names are converted to lower case.
/// </param>
/// <param name="unpack">
/// If True, the returned array is transposed, so that arguments may be
/// unpacked using x, y, z = loadtxt(...)
/// </param>
/// <param name="usemask">
/// If True, return a masked array.<br></br>
///
/// If False, return a regular array.
/// </param>
/// <param name="loose">
/// If True, do not raise errors for invalid values.
/// </param>
/// <param name="invalid_raise">
/// If True, an exception is raised if an inconsistency is detected in the
/// number of columns.<br></br>
///
/// If False, a warning is emitted and the offending lines are skipped.
/// </param>
/// <param name="max_rows">
/// The maximum number of rows to read.<br></br>
/// Must not be used with skip_footer
/// at the same time.<br></br>
/// If given, the value must be at least 1.<br></br>
/// Default is
/// to read the entire file.
/// </param>
/// <param name="encoding">
/// Encoding used to decode the inputfile.<br></br>
/// Does not apply when fname is
/// a file object.<br></br>
/// The special value ‘bytes’ enables backward compatibility
/// workarounds that ensure that you receive byte arrays when possible
/// and passes latin1 encoded strings to converters.<br></br>
/// Override this value to
/// receive unicode arrays and pass strings as input to converters.<br></br>
/// If set
/// to None the system default is used.<br></br>
/// The default value is ‘bytes’.
/// </param>
/// <returns>
/// Data read from the text file.<br></br>
/// If usemask is True, this is a
/// masked array.
/// </returns>
public NDarray genfromtxt(string fname, Dtype dtype = null, string comments = null, string delimiter = null, int? skiprows = null, int? skip_header = 0, int? skip_footer = 0, variable converters = null, variable missing = null, variable missing_values = null, variable filling_values = null, sequence usecols = null, {None names = null, sequence excludelist = null, string deletechars = null, string defaultfmt = "f%i", bool? autostrip = false, char replace_space = "_", {True case_sensitive = true, bool? unpack = null, bool? usemask = false, bool? loose = true, bool? invalid_raise = true, int? max_rows = null, string encoding = "bytes")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
fname,
});
var kwargs=new PyDict();
if (dtype!=null) kwargs["dtype"]=ToPython(dtype);
if (comments!=null) kwargs["comments"]=ToPython(comments);
if (delimiter!=null) kwargs["delimiter"]=ToPython(delimiter);
if (skiprows!=null) kwargs["skiprows"]=ToPython(skiprows);
if (skip_header!=0) kwargs["skip_header"]=ToPython(skip_header);
if (skip_footer!=0) kwargs["skip_footer"]=ToPython(skip_footer);
if (converters!=null) kwargs["converters"]=ToPython(converters);
if (missing!=null) kwargs["missing"]=ToPython(missing);
if (missing_values!=null) kwargs["missing_values"]=ToPython(missing_values);
if (filling_values!=null) kwargs["filling_values"]=ToPython(filling_values);
if (usecols!=null) kwargs["usecols"]=ToPython(usecols);
if (names!=null) kwargs["names"]=ToPython(names);
if (excludelist!=null) kwargs["excludelist"]=ToPython(excludelist);
if (deletechars!=null) kwargs["deletechars"]=ToPython(deletechars);
if (defaultfmt!="f%i") kwargs["defaultfmt"]=ToPython(defaultfmt);
if (autostrip!=false) kwargs["autostrip"]=ToPython(autostrip);
if (replace_space!="_") kwargs["replace_space"]=ToPython(replace_space);
if (case_sensitive!=true) kwargs["case_sensitive"]=ToPython(case_sensitive);
if (unpack!=null) kwargs["unpack"]=ToPython(unpack);
if (usemask!=false) kwargs["usemask"]=ToPython(usemask);
if (loose!=true) kwargs["loose"]=ToPython(loose);
if (invalid_raise!=true) kwargs["invalid_raise"]=ToPython(invalid_raise);
if (max_rows!=null) kwargs["max_rows"]=ToPython(max_rows);
if (encoding!="bytes") kwargs["encoding"]=ToPython(encoding);
dynamic py = __self__.InvokeMethod("genfromtxt", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
*/
/// <summary>
/// Construct an array from a text file, using regular expression parsing.<br></br>
///
/// The returned array is always a structured array, and is constructed from
/// all matches of the regular expression in the file.<br></br>
/// Groups in the regular
/// expression are converted to fields of the structured array.<br></br>
///
/// Notes
///
/// Dtypes for structured arrays can be specified in several forms, but all
/// forms specify at least the data type and field name.<br></br>
/// For details see
/// doc.structured_arrays.
/// </summary>
/// <param name="file">
/// File name or file object to read.
/// </param>
/// <param name="regexp">
/// Regular expression used to parse the file.<br></br>
///
/// Groups in the regular expression correspond to fields in the dtype.
/// </param>
/// <param name="dtype">
/// Dtype for the structured array.
/// </param>
/// <param name="encoding">
/// Encoding used to decode the inputfile.<br></br>
/// Does not apply to input streams.
/// </param>
/// <returns>
/// The output array, containing the part of the content of file that
/// was matched by regexp.<br></br>
/// output is always a structured array.
/// </returns>
public NDarray fromregex(string file, string regexp, Dtype dtype, string encoding = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
file,
regexp,
dtype,
});
var kwargs=new PyDict();
if (encoding!=null) kwargs["encoding"]=ToPython(encoding);
dynamic py = __self__.InvokeMethod("fromregex", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Write array to a file as text or binary (default).<br></br>
///
/// Data is always written in ‘C’ order, independent of the order of a.<br></br>
///
/// The data produced by this method can be recovered using the function
/// fromfile().<br></br>
///
/// Notes
///
/// This is a convenience function for quick storage of array data.<br></br>
///
/// Information on endianness and precision is lost, so this method is not a
/// good choice for files intended to archive data or transport data between
/// machines with different endianness.<br></br>
/// Some of these problems can be overcome
/// by outputting the data as text files, at the expense of speed and file
/// size.<br></br>
///
/// When fid is a file object, array contents are directly written to the
/// file, bypassing the file object’s write method.<br></br>
/// As a result, tofile
/// cannot be used with files objects supporting compression (e.g., GzipFile)
/// or file-like objects that do not support fileno() (e.g., BytesIO).
/// </summary>
/// <param name="fid">
/// An open file object, or a string containing a filename.
/// </param>
/// <param name="sep">
/// Separator between array items for text output.<br></br>
///
/// If “” (empty), a binary file is written, equivalent to
/// file.write(a.tobytes()).
/// </param>
/// <param name="format">
/// Format string for text file output.<br></br>
///
/// Each entry in the array is formatted to text by first converting
/// it to the closest Python type, and then using “format” % item.
/// </param>
public void tofile(string fid, string sep, string format)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
fid,
sep,
format,
});
var kwargs=new PyDict();
dynamic py = __self__.InvokeMethod("tofile", pyargs, kwargs);
}
/*
/// <summary>
/// Return the array as a (possibly nested) list.<br></br>
///
/// Return a copy of the array data as a (nested) Python list.<br></br>
///
/// Data items are converted to the nearest compatible Python type.<br></br>
///
/// Notes
///
/// The array may be recreated, a = np.array(a.tolist()).
/// </summary>
/// <returns>
/// The possibly nested list of array elements.
/// </returns>
public List<T> tolist<T>()
{
//auto-generated code, do not change
var __self__=self;
dynamic py = __self__.InvokeMethod("tolist");
return ToCsharp<List<T>>(py);
}
*/
/*
/// <summary>
/// Return a string representation of an array.<br></br>
///
/// Notes
///
/// If a formatter is specified for a certain type, the precision keyword is
/// ignored for that type.<br></br>
///
/// This is a very flexible function; array_repr and array_str are using
/// array2string internally so keywords with the same name should work
/// identically in all three functions.
/// </summary>
/// <param name="a">
/// Input array.
/// </param>
/// <param name="max_line_width">
/// The maximum number of columns the string should span.<br></br>
/// Newline
/// characters splits the string appropriately after array elements.
/// </param>
/// <param name="precision">
/// Floating point precision.<br></br>
/// Default is the current printing
/// precision (usually 8), which can be altered using set_printoptions.
/// </param>
/// <param name="suppress_small">
/// Represent very small numbers as zero.<br></br>
/// A number is “very small” if it
/// is smaller than the current printing precision.
/// </param>
/// <param name="separator">
/// Inserted between elements.
/// </param>
/// <param name="suffix">
/// The length of the prefix and suffix strings are used to respectively
/// align and wrap the output.<br></br>
/// An array is typically printed as:
///
/// The output is left-padded by the length of the prefix string, and
/// wrapping is forced at the column max_line_width - len(suffix).<br></br>
///
/// It should be noted that the content of prefix and suffix strings are
/// not included in the output.
/// </param>
/// <param name="formatter">
/// If not None, the keys should indicate the type(s) that the respective
/// formatting function applies to.<br></br>
/// Callables should return a string.<br></br>
///
/// Types that are not specified (by their corresponding keys) are handled
/// by the default formatters.<br></br>
/// Individual types for which a formatter
/// can be set are:
///
/// Other keys that can be used to set a group of types at once are:
/// </param>
/// <param name="threshold">
/// Total number of array elements which trigger summarization
/// rather than full repr.
/// </param>
/// <param name="edgeitems">
/// Number of array items in summary at beginning and end of
/// each dimension.
/// </param>
/// <param name="sign">
/// Controls printing of the sign of floating-point types.<br></br>
/// If ‘+’, always
/// print the sign of positive values.<br></br>
/// If ‘ ‘, always prints a space
/// (whitespace character) in the sign position of positive values.<br></br>
/// If
/// ‘-‘, omit the sign character of positive values.
/// </param>
/// <param name="floatmode">
/// Controls the interpretation of the precision option for
/// floating-point types.<br></br>
/// Can take the following values:
/// </param>
/// <param name="legacy">
/// If set to the string ‘1.13’ enables 1.13 legacy printing mode.<br></br>
/// This
/// approximates numpy 1.13 print output by including a space in the sign
/// position of floats and different behavior for 0d arrays.<br></br>
/// If set to
/// False, disables legacy mode.<br></br>
/// Unrecognized strings will be ignored
/// with a warning for forward compatibility.
/// </param>
/// <returns>
/// String representation of the array.
/// </returns>
public string array2string(NDarray a, int? max_line_width = null, int? precision = null, bool? suppress_small = null, string separator = " ", string prefix = "", string suffix = "", dict of callables formatter = null, int? threshold = null, int? edgeitems = null, string sign = null, string floatmode = null, string or False legacy = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
a,
});
var kwargs=new PyDict();
if (max_line_width!=null) kwargs["max_line_width"]=ToPython(max_line_width);
if (precision!=null) kwargs["precision"]=ToPython(precision);
if (suppress_small!=null) kwargs["suppress_small"]=ToPython(suppress_small);
if (separator!=" ") kwargs["separator"]=ToPython(separator);
if (prefix!="") kwargs["prefix"]=ToPython(prefix);
if (suffix!="") kwargs["suffix"]=ToPython(suffix);
if (formatter!=null) kwargs["formatter"]=ToPython(formatter);
if (threshold!=null) kwargs["threshold"]=ToPython(threshold);
if (edgeitems!=null) kwargs["edgeitems"]=ToPython(edgeitems);
if (sign!=null) kwargs["sign"]=ToPython(sign);
if (floatmode!=null) kwargs["floatmode"]=ToPython(floatmode);
if (legacy!=null) kwargs["legacy"]=ToPython(legacy);
dynamic py = __self__.InvokeMethod("array2string", pyargs, kwargs);
return ToCsharp<string>(py);
}
*/
/// <summary>
/// Return the string representation of an array.
/// </summary>
/// <param name="arr">
/// Input array.
/// </param>
/// <param name="max_line_width">
/// The maximum number of columns the string should span.<br></br>
/// Newline
/// characters split the string appropriately after array elements.
/// </param>
/// <param name="precision">
/// Floating point precision.<br></br>
/// Default is the current printing precision
/// (usually 8), which can be altered using set_printoptions.
/// </param>
/// <param name="suppress_small">
/// Represent very small numbers as zero, default is False.<br></br>
/// Very small
/// is defined by precision, if the precision is 8 then
/// numbers smaller than 5e-9 are represented as zero.
/// </param>
/// <returns>
/// The string representation of an array.
/// </returns>
public string array_repr(NDarray arr, int? max_line_width = null, int? precision = null, bool? suppress_small = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
arr,
});
var kwargs=new PyDict();
if (max_line_width!=null) kwargs["max_line_width"]=ToPython(max_line_width);
if (precision!=null) kwargs["precision"]=ToPython(precision);
if (suppress_small!=null) kwargs["suppress_small"]=ToPython(suppress_small);
dynamic py = __self__.InvokeMethod("array_repr", pyargs, kwargs);
return ToCsharp<string>(py);
}
/// <summary>
/// Return a string representation of the data in an array.<br></br>
///
/// The data in the array is returned as a single string.<br></br>
/// This function is
/// similar to array_repr, the difference being that array_repr also
/// returns information on the kind of array and its data type.
/// </summary>
/// <param name="a">
/// Input array.
/// </param>
/// <param name="max_line_width">
/// Inserts newlines if text is longer than max_line_width.<br></br>
/// The
/// default is, indirectly, 75.
/// </param>
/// <param name="precision">
/// Floating point precision.<br></br>
/// Default is the current printing precision
/// (usually 8), which can be altered using set_printoptions.
/// </param>
/// <param name="suppress_small">
/// Represent numbers “very close” to zero as zero; default is False.<br></br>
///
/// Very close is defined by precision: if the precision is 8, e.g.,
/// numbers smaller (in absolute value) than 5e-9 are represented as
/// zero.
/// </param>
public void array_str(NDarray a, int? max_line_width = null, int? precision = null, bool? suppress_small = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
a,
});
var kwargs=new PyDict();
if (max_line_width!=null) kwargs["max_line_width"]=ToPython(max_line_width);
if (precision!=null) kwargs["precision"]=ToPython(precision);
if (suppress_small!=null) kwargs["suppress_small"]=ToPython(suppress_small);
dynamic py = __self__.InvokeMethod("array_str", pyargs, kwargs);
}
/*
/// <summary>
/// Format a floating-point scalar as a decimal string in positional notation.<br></br>
///
/// Provides control over rounding, trimming and padding.<br></br>
/// Uses and assumes
/// IEEE unbiased rounding.<br></br>
/// Uses the “Dragon4” algorithm.
/// </summary>
/// <param name="x">
/// Value to format.
/// </param>
/// <param name="precision">
/// Maximum number of digits to print.<br></br>
/// May be None if unique is
/// True, but must be an integer if unique is False.
/// </param>
/// <param name="unique">
/// If True, use a digit-generation strategy which gives the shortest
/// representation which uniquely identifies the floating-point number from
/// other values of the same type, by judicious rounding.<br></br>
/// If precision
/// was omitted, print out all necessary digits, otherwise digit generation
/// is cut off after precision digits and the remaining value is rounded.<br></br>
///
/// If False, digits are generated as if printing an infinite-precision
/// value and stopping after precision digits, rounding the remaining
/// value.
/// </param>
/// <param name="fractional">
/// If True, the cutoff of precision digits refers to the total number
/// of digits after the decimal point, including leading zeros.<br></br>
///
/// If False, precision refers to the total number of significant
/// digits, before or after the decimal point, ignoring leading zeros.
/// </param>
/// <param name="trim">
/// Controls post-processing trimming of trailing digits, as follows:
/// </param>
/// <param name="sign">
/// Whether to show the sign for positive values.
/// </param>
/// <param name="pad_left">
/// Pad the left side of the string with whitespace until at least that
/// many characters are to the left of the decimal point.
/// </param>
/// <param name="pad_right">
/// Pad the right side of the string with whitespace until at least that
/// many characters are to the right of the decimal point.
/// </param>
/// <returns>
/// The string representation of the floating point value
/// </returns>
public string format_float_positional(python float or numpy floating scalar x, non-negative integer or None precision = null, bool? unique = true, bool? fractional = true, one of ‘k’ trim = "k", bool? sign = false, non-negative integer pad_left = null, non-negative integer pad_right = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
x,
});
var kwargs=new PyDict();
if (precision!=null) kwargs["precision"]=ToPython(precision);
if (unique!=true) kwargs["unique"]=ToPython(unique);
if (fractional!=true) kwargs["fractional"]=ToPython(fractional);
if (trim!="k") kwargs["trim"]=ToPython(trim);
if (sign!=false) kwargs["sign"]=ToPython(sign);
if (pad_left!=null) kwargs["pad_left"]=ToPython(pad_left);
if (pad_right!=null) kwargs["pad_right"]=ToPython(pad_right);
dynamic py = __self__.InvokeMethod("format_float_positional", pyargs, kwargs);
return ToCsharp<string>(py);
}
*/
/*
/// <summary>
/// Format a floating-point scalar as a decimal string in scientific notation.<br></br>
///
/// Provides control over rounding, trimming and padding.<br></br>
/// Uses and assumes
/// IEEE unbiased rounding.<br></br>
/// Uses the “Dragon4” algorithm.
/// </summary>
/// <param name="x">
/// Value to format.
/// </param>
/// <param name="precision">
/// Maximum number of digits to print.<br></br>
/// May be None if unique is
/// True, but must be an integer if unique is False.
/// </param>
/// <param name="unique">
/// If True, use a digit-generation strategy which gives the shortest
/// representation which uniquely identifies the floating-point number from
/// other values of the same type, by judicious rounding.<br></br>
/// If precision
/// was omitted, print all necessary digits, otherwise digit generation is
/// cut off after precision digits and the remaining value is rounded.<br></br>
///
/// If False, digits are generated as if printing an infinite-precision
/// value and stopping after precision digits, rounding the remaining
/// value.
/// </param>
/// <param name="trim">
/// Controls post-processing trimming of trailing digits, as follows:
/// </param>
/// <param name="sign">
/// Whether to show the sign for positive values.
/// </param>
/// <param name="pad_left">
/// Pad the left side of the string with whitespace until at least that
/// many characters are to the left of the decimal point.
/// </param>
/// <param name="exp_digits">
/// Pad the exponent with zeros until it contains at least this many digits.<br></br>
///
/// If omitted, the exponent will be at least 2 digits.
/// </param>
/// <returns>
/// The string representation of the floating point value
/// </returns>
public string format_float_scientific(python float or numpy floating scalar x, non-negative integer or None precision = null, bool? unique = true, one of ‘k’ trim = "k", bool? sign = false, non-negative integer pad_left = null, non-negative integer exp_digits = null)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
x,
});
var kwargs=new PyDict();
if (precision!=null) kwargs["precision"]=ToPython(precision);
if (unique!=true) kwargs["unique"]=ToPython(unique);
if (trim!="k") kwargs["trim"]=ToPython(trim);
if (sign!=false) kwargs["sign"]=ToPython(sign);
if (pad_left!=null) kwargs["pad_left"]=ToPython(pad_left);
if (exp_digits!=null) kwargs["exp_digits"]=ToPython(exp_digits);
dynamic py = __self__.InvokeMethod("format_float_scientific", pyargs, kwargs);
return ToCsharp<string>(py);
}
*/
/// <summary>
/// Create a memory-map to an array stored in a binary file on disk.<br></br>
///
/// Memory-mapped files are used for accessing small segments of large files