ndtypes 0.2.0dev4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +50 -0
  3. data/Gemfile +2 -0
  4. data/History.md +0 -0
  5. data/README.md +19 -0
  6. data/Rakefile +125 -0
  7. data/ext/ruby_ndtypes/extconf.rb +55 -0
  8. data/ext/ruby_ndtypes/gc_guard.c +36 -0
  9. data/ext/ruby_ndtypes/gc_guard.h +12 -0
  10. data/ext/ruby_ndtypes/ndtypes/AUTHORS.txt +5 -0
  11. data/ext/ruby_ndtypes/ndtypes/INSTALL.txt +101 -0
  12. data/ext/ruby_ndtypes/ndtypes/LICENSE.txt +29 -0
  13. data/ext/ruby_ndtypes/ndtypes/MANIFEST.in +3 -0
  14. data/ext/ruby_ndtypes/ndtypes/Makefile.in +87 -0
  15. data/ext/ruby_ndtypes/ndtypes/README.rst +47 -0
  16. data/ext/ruby_ndtypes/ndtypes/config.guess +1530 -0
  17. data/ext/ruby_ndtypes/ndtypes/config.h.in +67 -0
  18. data/ext/ruby_ndtypes/ndtypes/config.sub +1782 -0
  19. data/ext/ruby_ndtypes/ndtypes/configure +5260 -0
  20. data/ext/ruby_ndtypes/ndtypes/configure.ac +161 -0
  21. data/ext/ruby_ndtypes/ndtypes/doc/Makefile +14 -0
  22. data/ext/ruby_ndtypes/ndtypes/doc/_static/copybutton.js +66 -0
  23. data/ext/ruby_ndtypes/ndtypes/doc/conf.py +26 -0
  24. data/ext/ruby_ndtypes/ndtypes/doc/grammar/grammar.rst +27 -0
  25. data/ext/ruby_ndtypes/ndtypes/doc/index.rst +56 -0
  26. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/context.rst +131 -0
  27. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/encodings.rst +68 -0
  28. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/fields-values.rst +175 -0
  29. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/functions.rst +72 -0
  30. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/index.rst +43 -0
  31. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/init.rst +48 -0
  32. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/io.rst +100 -0
  33. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/memory.rst +124 -0
  34. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/predicates.rst +110 -0
  35. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/typedef.rst +31 -0
  36. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/types.rst +594 -0
  37. data/ext/ruby_ndtypes/ndtypes/doc/libndtypes/util.rst +166 -0
  38. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/buffer-protocol.rst +27 -0
  39. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/index.rst +21 -0
  40. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/pattern-matching.rst +330 -0
  41. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/quickstart.rst +144 -0
  42. data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/types.rst +544 -0
  43. data/ext/ruby_ndtypes/ndtypes/doc/releases/index.rst +35 -0
  44. data/ext/ruby_ndtypes/ndtypes/install-sh +527 -0
  45. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.in +271 -0
  46. data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.vc +269 -0
  47. data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.c +230 -0
  48. data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.c +268 -0
  49. data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.h +109 -0
  50. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile.in +73 -0
  51. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile.vc +70 -0
  52. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/README.txt +16 -0
  53. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.c +2179 -0
  54. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.h +134 -0
  55. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.y +428 -0
  56. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.c +2543 -0
  57. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.h +735 -0
  58. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.l +176 -0
  59. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.c +543 -0
  60. data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.c +110 -0
  61. data/ext/ruby_ndtypes/ndtypes/libndtypes/context.c +228 -0
  62. data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.c +634 -0
  63. data/ext/ruby_ndtypes/ndtypes/libndtypes/encodings.c +116 -0
  64. data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.c +288 -0
  65. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +3067 -0
  66. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.h +180 -0
  67. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +417 -0
  68. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +1658 -0
  69. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.c +2773 -0
  70. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.h +734 -0
  71. data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.l +222 -0
  72. data/ext/ruby_ndtypes/ndtypes/libndtypes/match.c +1132 -0
  73. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.c +2323 -0
  74. data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h.in +893 -0
  75. data/ext/ruby_ndtypes/ndtypes/libndtypes/overflow.h +161 -0
  76. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.c +473 -0
  77. data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.h +92 -0
  78. data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.c +246 -0
  79. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.c +269 -0
  80. data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.h +197 -0
  81. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile.in +48 -0
  82. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile.vc +46 -0
  83. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.c +1007 -0
  84. data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.c +442 -0
  85. data/ext/ruby_ndtypes/ndtypes/libndtypes/slice.h +42 -0
  86. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.c +238 -0
  87. data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.h +50 -0
  88. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.c +371 -0
  89. data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.h +100 -0
  90. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.in +55 -0
  91. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.vc +45 -0
  92. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/alloc_fail.c +82 -0
  93. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/alloc_fail.h +49 -0
  94. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/runtest.c +1657 -0
  95. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test.h +85 -0
  96. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_array.c +115 -0
  97. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_buffer.c +137 -0
  98. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_indent.c +201 -0
  99. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +2397 -0
  100. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_numba.c +57 -0
  101. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +349 -0
  102. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +27839 -0
  103. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +350 -0
  104. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_record.c +231 -0
  105. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +375 -0
  106. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typedef.c +65 -0
  107. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/valgrind.supp +30 -0
  108. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/bench.c +79 -0
  109. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/indent.c +94 -0
  110. data/ext/ruby_ndtypes/ndtypes/libndtypes/tools/print_ast.c +96 -0
  111. data/ext/ruby_ndtypes/ndtypes/libndtypes/util.c +474 -0
  112. data/ext/ruby_ndtypes/ndtypes/libndtypes/values.c +228 -0
  113. data/ext/ruby_ndtypes/ndtypes/python/bench.py +49 -0
  114. data/ext/ruby_ndtypes/ndtypes/python/ndt_randtype.py +409 -0
  115. data/ext/ruby_ndtypes/ndtypes/python/ndt_support.py +14 -0
  116. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/__init__.py +70 -0
  117. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +1332 -0
  118. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/docstrings.h +319 -0
  119. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/pyndtypes.h +154 -0
  120. data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +1977 -0
  121. data/ext/ruby_ndtypes/ndtypes/setup.py +288 -0
  122. data/ext/ruby_ndtypes/ndtypes/vcbuild/INSTALL.txt +41 -0
  123. data/ext/ruby_ndtypes/ndtypes/vcbuild/runtest32.bat +15 -0
  124. data/ext/ruby_ndtypes/ndtypes/vcbuild/runtest64.bat +13 -0
  125. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcbuild32.bat +38 -0
  126. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcbuild64.bat +38 -0
  127. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcclean.bat +13 -0
  128. data/ext/ruby_ndtypes/ndtypes/vcbuild/vcdistclean.bat +14 -0
  129. data/ext/ruby_ndtypes/ruby_ndtypes.c +1003 -0
  130. data/ext/ruby_ndtypes/ruby_ndtypes.h +37 -0
  131. data/ext/ruby_ndtypes/ruby_ndtypes_internal.h +28 -0
  132. data/lib/ndtypes.rb +45 -0
  133. data/lib/ndtypes/errors.rb +2 -0
  134. data/lib/ndtypes/version.rb +6 -0
  135. data/ndtypes.gemspec +47 -0
  136. data/spec/gc_table_spec.rb +10 -0
  137. data/spec/ndtypes_spec.rb +289 -0
  138. data/spec/spec_helper.rb +241 -0
  139. metadata +242 -0
@@ -0,0 +1,228 @@
1
+ /*
2
+ * BSD 3-Clause License
3
+ *
4
+ * Copyright (c) 2017-2018, plures
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * 3. Neither the name of the copyright holder nor the names of its
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+
34
+ #include <string.h>
35
+ #include <assert.h>
36
+ #include "ndtypes.h"
37
+ #include "seq.h"
38
+
39
+
40
+ /*****************************************************************************/
41
+ /* Values for the categorical type */
42
+ /*****************************************************************************/
43
+
44
+ void
45
+ ndt_value_del(ndt_value_t *mem)
46
+ {
47
+ if (mem == NULL) {
48
+ return;
49
+ }
50
+
51
+ if (mem->tag == ValString) {
52
+ ndt_free(mem->ValString);
53
+ }
54
+
55
+ ndt_free(mem);
56
+ }
57
+
58
+ void
59
+ ndt_value_array_del(ndt_value_t *mem, int64_t ntypes)
60
+ {
61
+ int64_t i;
62
+
63
+ if (mem == NULL) {
64
+ return;
65
+ }
66
+
67
+ for (i = 0; i < ntypes; i++) {
68
+ if (mem[i].tag == ValString) {
69
+ ndt_free(mem[i].ValString);
70
+ }
71
+ }
72
+
73
+ ndt_free(mem);
74
+ }
75
+
76
+ /* Value sequences */
77
+ NDT_SEQ_NEW(ndt_value)
78
+ NDT_SEQ_DEL(ndt_value)
79
+ NDT_SEQ_GROW(ndt_value)
80
+ NDT_SEQ_APPEND(ndt_value)
81
+ NDT_SEQ_FINALIZE(ndt_value)
82
+
83
+
84
+ /* Return a new ndt memory buffer. Input types are restricted. */
85
+ ndt_value_t *
86
+ ndt_value_from_number(enum ndt_value tag, char *v, ndt_context_t *ctx)
87
+ {
88
+ ndt_value_t *mem;
89
+
90
+ mem = ndt_alloc_size(sizeof *mem);
91
+ if (mem == NULL) {
92
+ ndt_free(v);
93
+ return ndt_memory_error(ctx);
94
+ }
95
+ mem->tag = tag;
96
+
97
+ switch (tag) {
98
+ case ValBool:
99
+ mem->ValBool = ndt_strtobool(v, ctx);
100
+ break;
101
+ case ValInt64:
102
+ mem->ValInt64 = (int64_t)ndt_strtoll(v, INT64_MIN, INT64_MAX, ctx);
103
+ break;
104
+ case ValFloat64:
105
+ mem->ValFloat64 = ndt_strtod(v, ctx);
106
+ break;
107
+ case ValString: case ValNA:
108
+ ndt_err_format(ctx, NDT_InvalidArgumentError, "expected number tag");
109
+ break;
110
+ }
111
+
112
+ ndt_free(v);
113
+ if (ndt_err_occurred(ctx)) {
114
+ ndt_free(mem);
115
+ return NULL;
116
+ }
117
+
118
+ return mem;
119
+ }
120
+
121
+ /* Return a new ndt memory buffer. The input type is 'string'. */
122
+ ndt_value_t *
123
+ ndt_value_from_string(char *v, ndt_context_t *ctx)
124
+ {
125
+ ndt_value_t *mem;
126
+
127
+ mem = ndt_alloc_size(sizeof *mem);
128
+ if (mem == NULL) {
129
+ ndt_free(v);
130
+ return ndt_memory_error(ctx);
131
+ }
132
+
133
+ /* XXX: check utf8 */
134
+ mem->tag = ValString;
135
+ mem->ValString = v;
136
+
137
+ return mem;
138
+ }
139
+
140
+ /* Return a new ndt memory buffer. The input type is 'NA'. */
141
+ ndt_value_t *
142
+ ndt_value_na(ndt_context_t *ctx)
143
+ {
144
+ ndt_value_t *mem;
145
+
146
+ mem = ndt_alloc_size(sizeof *mem);
147
+ if (mem == NULL) {
148
+ return ndt_memory_error(ctx);
149
+ }
150
+ mem->tag = ValNA;
151
+
152
+ return mem;
153
+ }
154
+
155
+ /* Equality: NA does not compare equal to anything. */
156
+ int
157
+ ndt_value_equal(const ndt_value_t *x, const ndt_value_t *y)
158
+ {
159
+ if (x->tag != y->tag) {
160
+ return 0;
161
+ }
162
+
163
+ switch(x->tag) {
164
+ case ValBool:
165
+ return x->ValBool == y->ValBool;
166
+ case ValInt64:
167
+ return x->ValInt64 == y->ValInt64;
168
+ case ValFloat64:
169
+ return x->ValFloat64 == y->ValFloat64;
170
+ case ValString:
171
+ return strcmp(x->ValString, y->ValString) == 0;
172
+ case ValNA:
173
+ return 0;
174
+ }
175
+
176
+ /* NOT REACHED: tags should be exhaustive. */
177
+ ndt_internal_error("invalid value");
178
+ }
179
+
180
+ /* Structural equality: NA compares equal to itself. */
181
+ int
182
+ ndt_value_mem_equal(const ndt_value_t *x, const ndt_value_t *y)
183
+ {
184
+ if (x->tag != y->tag) {
185
+ return 0;
186
+ }
187
+
188
+ switch(x->tag) {
189
+ case ValBool:
190
+ return x->ValBool == y->ValBool;
191
+ case ValInt64:
192
+ return x->ValInt64 == y->ValInt64;
193
+ case ValFloat64:
194
+ return x->ValFloat64 == y->ValFloat64;
195
+ case ValString:
196
+ return strcmp(x->ValString, y->ValString) == 0;
197
+ case ValNA:
198
+ return 1;
199
+ }
200
+
201
+ /* NOT REACHED: tags should be exhaustive. */
202
+ ndt_internal_error("invalid value");
203
+ }
204
+
205
+ /* Sort order: NA compares equal to itself. */
206
+ int
207
+ ndt_value_compare(const ndt_value_t *x, const ndt_value_t *y)
208
+ {
209
+ if (x->tag != y->tag) {
210
+ return x->tag - y->tag;
211
+ }
212
+
213
+ switch(x->tag) {
214
+ case ValBool:
215
+ return x->ValBool < y->ValBool ? -1 : x->ValBool != y->ValBool;
216
+ case ValInt64:
217
+ return x->ValInt64 < y->ValInt64 ? -1 : x->ValInt64 != y->ValInt64;
218
+ case ValFloat64:
219
+ return x->ValFloat64 < y->ValFloat64 ? -1 : x->ValFloat64 != y->ValFloat64;
220
+ case ValString:
221
+ return strcmp(x->ValString, y->ValString);
222
+ case ValNA:
223
+ return 0;
224
+ }
225
+
226
+ /* NOT REACHED: tags should be exhaustive. */
227
+ ndt_internal_error("invalid value");
228
+ }
@@ -0,0 +1,49 @@
1
+ from ndtypes import *
2
+ import time
3
+
4
+ # =============================================================================
5
+ # Type with huge number of offsets
6
+ # =============================================================================
7
+
8
+ s = "var(offsets=[0,10000000]) * var(offsets=%s) * int64" % list(range(10000001))
9
+ print("Parse 10_000_000 var offsets:")
10
+ start = time.time()
11
+ t = ndt(s)
12
+ end = time.time()
13
+ print(end-start)
14
+
15
+
16
+ b = t.serialize()
17
+ print("\nDeserialize 10_000_000 var offsets:")
18
+ start = time.time()
19
+ u = ndt.deserialize(b)
20
+ end = time.time()
21
+ print(end-start)
22
+
23
+ assert t == u
24
+
25
+
26
+ # =============================================================================
27
+ # Large type
28
+ # =============================================================================
29
+
30
+ s = """
31
+ {battingpost: 100 * {yearID: ?int32, round: ?string, playerID: ?string, teamID: ?string, lgID: (?string, int64, 5 * 10 * {a: complex128, b: ?int32}), G: ?int32, AB: ?int32, R: ?int32, H: (int32, 10 * int32), HR: {a: 10 * float64, b: 10 * int32}, RBI: ?int32, SB: ?int32, CS: ?int32, BB: ?int32, SO: ?int32, IBB: ?int32, HBP: ?int32, SH: ?int32, SF: ?int32, GIDP: ?int32, AString: fixed_string(100,'utf32'), BString: fixed_string(100), CBytes: bytes(align=16), DBytes: fixed_bytes(size=1600, align=16)}, awardsmanagers: 10 * {managerID: ?string, awardID: ?string, yearID: ?int32, lgID: ?string, tie: ?string, notes: ?string}, hofold: 10 * {hofID: ?string, yearid: ?int32, votedBy: ?string, ballots: ?int32, votes: ?int32, inducted: ?string, category: ?string}, salaries: 10 * {yearID: ?int32, teamID: ?string, lgID: ?string, playerID: ?string, salary: ?float64}, pitchingpost: 10 * {playerID: ?string, yearID: ?int32, round: ?string, teamID: ?string, lgID: ?string, W: ?int32, L: ?int32, G: ?int32, GS: ?int32, CG: ?int32, SHO: ?int32, SV: ?int32, IPouts: ?int32, H: ?int32, ER: ?int32, HR: ?int32, BB: ?int32, SO: ?int32, BAOpp: ?float64, ERA: ?float64, IBB: ?int32, WP: ?int32, HBP: ?int32, BK: ?int32, BFP: ?int32, GF: ?int32, R: ?int32, SH: ?int32, SF: ?int32, GIDP: ?int32}, managers: 10 * {managerID: ?string, yearID: ?int32, teamID: ?string, lgID: ?string, inseason: ?int32, G: ?int32, W: ?int32, L: ?int32, rank: ?int32, plyrMgr: ?string}, teams: 10 * {yearID: ?int32, lgID: ?string, teamID: ?string, franchID: ?string, divID: ?string, Rank: ?int32, G: ?int32, Ghome: ?int32, W: ?int32, L: ?int32, DivWin: ?string, WCWin: ?string, LgWin: ?string, WSWin: ?string, R: ?int32, AB: ?int32, H: ?int32, B: ?int32, B: ?int32, HR: ?int32, BB: ?int32, SO: ?int32, SB: ?int32, CS: ?int32, HBP: ?int32, SF: ?int32, RA: ?int32, ER: ?int32, ERA: ?float64, CG: ?int32, SHO: ?int32, SV: ?int32, IPouts: ?int32, HA: ?int32, HRA: ?int32, BBA: ?int32, SOA: ?int32, E: ?int32, DP: ?int32, FP: ?float64, name: ?string, park: ?string, attendance: ?int32, BPF: ?int32, PPF: ?int32, teamIDBR: ?string, teamIDlahman45: ?string, teamIDretro: ?string}}
32
+ """
33
+
34
+ print("\nParse large type (100_000 repetitions):")
35
+ start = time.time()
36
+ for i in range(100000):
37
+ t = ndt(s)
38
+ end = time.time()
39
+ print(end-start)
40
+
41
+ b = t.serialize()
42
+ print("\nDeserialize large type (100_000 repetitions):")
43
+ start = time.time()
44
+ for i in range(100000):
45
+ u = ndt.deserialize(b)
46
+ end = time.time()
47
+ print(end-start)
48
+
49
+ assert t == u
@@ -0,0 +1,409 @@
1
+ #
2
+ # BSD 3-Clause License
3
+ #
4
+ # Copyright (c) 2017-2018, plures
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are met:
9
+ #
10
+ # 1. Redistributions of source code must retain the above copyright notice,
11
+ # this list of conditions and the following disclaimer.
12
+ #
13
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ # this list of conditions and the following disclaimer in the documentation
15
+ # and/or other materials provided with the distribution.
16
+ #
17
+ # 3. Neither the name of the copyright holder nor the names of its
18
+ # contributors may be used to endorse or promote products derived from
19
+ # this software without specific prior written permission.
20
+ #
21
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+
33
+ # Functions for generating test cases.
34
+
35
+ import sys
36
+ from itertools import accumulate, count, product
37
+ from collections import namedtuple
38
+ from random import randrange
39
+ from ndtypes import ndt, ApplySpec
40
+ from _testbuffer import get_sizeof_void_p
41
+
42
+
43
+ SIZEOF_PTR = get_sizeof_void_p()
44
+
45
+ Mem = namedtuple("Mem", "itemsize align")
46
+
47
+
48
+ # ======================================================================
49
+ # Check contiguous fixed dimensions
50
+ # ======================================================================
51
+
52
+ def c_datasize(t):
53
+ """Check the datasize of contiguous arrays."""
54
+ datasize = t.itemsize
55
+ for v in t.shape:
56
+ datasize *= v
57
+ return datasize
58
+
59
+
60
+ # ======================================================================
61
+ # Check fixed dimensions with arbitary strides
62
+ # ======================================================================
63
+
64
+ def verify_datasize(t):
65
+ """Verify the datasize of fixed dimensions with arbitrary strides."""
66
+
67
+ if t.itemsize == 0:
68
+ return t.datasize == 0
69
+ if t.datasize % t.itemsize:
70
+ return False
71
+ if t.ndim <= 0:
72
+ return t.ndim == 0 and not t.shape and not t.strides
73
+ if any(v < 0 for v in t.shape):
74
+ return False
75
+ if any(v % t.itemsize for v in t.strides):
76
+ return False
77
+
78
+ if 0 in t.shape:
79
+ return t.datasize == 0
80
+
81
+ imin = sum(t.strides[j]*(t.shape[j]-1) for j in range(t.ndim)
82
+ if t.strides[j] <= 0)
83
+ imax = sum(t.strides[j]*(t.shape[j]-1) for j in range(t.ndim)
84
+ if t.strides[j] > 0)
85
+
86
+ return t.datasize == (abs(imin) + imax + t.itemsize)
87
+
88
+
89
+ # ======================================================================
90
+ # Typed values
91
+ # ======================================================================
92
+
93
+ DTYPE_TEST_CASES = [
94
+ # Tuples
95
+ ("()", Mem(itemsize=0, align=1)),
96
+ ("(complex128)", Mem(itemsize=16, align=8)),
97
+
98
+ ("(int8, int64)", Mem(itemsize=16, align=8)),
99
+ ("(int8, int64, pack=1)", Mem(itemsize=9, align=1)),
100
+ ("(int8, int64, pack=2)", Mem(itemsize=10, align=2)),
101
+ ("(int8, int64, pack=4)", Mem(itemsize=12, align=4)),
102
+ ("(int8, int64, pack=8)", Mem(itemsize=16, align=8)),
103
+ ("(int8, int64, pack=16)", Mem(itemsize=32, align=16)),
104
+
105
+ ("(int8, int64, align=1)", Mem(itemsize=16, align=8)),
106
+ ("(int8, int64, align=2)", Mem(itemsize=16, align=8)),
107
+ ("(int8, int64, align=4)", Mem(itemsize=16, align=8)),
108
+ ("(int8, int64, align=8)", Mem(itemsize=16, align=8)),
109
+ ("(int8, int64, align=16)", Mem(itemsize=16, align=16)),
110
+
111
+ ("(int8 |align=1|, int64)", Mem(itemsize=16, align=8)),
112
+ ("(int8 |align=2|, int64)", Mem(itemsize=16, align=8)),
113
+ ("(int8 |align=4|, int64)", Mem(itemsize=16, align=8)),
114
+ ("(int8 |align=8|, int64)", Mem(itemsize=16, align=8)),
115
+ ("(int8 |align=16|, int64)", Mem(itemsize=16, align=16)),
116
+
117
+ ("(uint16, (complex64))", Mem(itemsize=12, align=4)),
118
+ ("(uint16, (complex64), pack=1)", Mem(itemsize=10, align=1)),
119
+ ("(uint16, (complex64), pack=2)", Mem(itemsize=10, align=2)),
120
+ ("(uint16, (complex64), pack=4)", Mem(itemsize=12, align=4)),
121
+ ("(uint16, (complex64), pack=8)", Mem(itemsize=16, align=8)),
122
+
123
+ ("(uint16, (complex64), align=1)", Mem(itemsize=12, align=4)),
124
+ ("(uint16, (complex64), align=2)", Mem(itemsize=12, align=4)),
125
+ ("(uint16, (complex64), align=4)", Mem(itemsize=12, align=4)),
126
+ ("(uint16, (complex64), align=8)", Mem(itemsize=16, align=8)),
127
+
128
+ # References to tuples
129
+ ("&(uint16, (complex64), align=1)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
130
+ ("(uint16, &(complex64), pack=1)", Mem(itemsize=2+SIZEOF_PTR, align=1)),
131
+
132
+ # Constructor containing references to tuples
133
+ ("Some(&(uint16, (complex64), align=1))", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
134
+ ("Some((uint16, &(complex64), pack=1))", Mem(itemsize=2+SIZEOF_PTR, align=1)),
135
+
136
+ # Optional tuples
137
+ ("?(uint16, (complex64), align=1)", Mem(itemsize=12, align=4)),
138
+ ("(uint16, ?(complex64), align=1)", Mem(itemsize=12, align=4)),
139
+ ("?(uint16, ?(complex64), align=1)", Mem(itemsize=12, align=4)),
140
+ ("?(uint16, (complex64), align=2)", Mem(itemsize=12, align=4)),
141
+ ("(uint16, ?(complex64), align=4)", Mem(itemsize=12, align=4)),
142
+ ("?(uint16, ?(complex64), align=8)", Mem(itemsize=16, align=8)),
143
+
144
+ # References to optional tuples or tuples with optional subtrees
145
+ ("&?(uint16, (complex64), align=1)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
146
+ ("&(uint16, ?(complex64), align=1)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
147
+
148
+ # Constructor containing optional tuples or tuples with optional subtrees
149
+ ("Some(?(uint16, (complex64), align=1))", Mem(itemsize=12, align=4)),
150
+ ("Some((uint16, ?(complex64), align=1))", Mem(itemsize=12, align=4)),
151
+
152
+ # Records
153
+ ("{}", Mem(itemsize=0, align=1)),
154
+ ("{x: complex128}", Mem(itemsize=16, align=8)),
155
+
156
+ ("{x: int8, y: int64}", Mem(itemsize=16, align=8)),
157
+ ("{x: int8, y: int64, pack=1}", Mem(itemsize=9, align=1)),
158
+ ("{x: int8, y: int64, pack=2}", Mem(itemsize=10, align=2)),
159
+ ("{x: int8, y: int64, pack=4}", Mem(itemsize=12, align=4)),
160
+ ("{x: int8, y: int64, pack=8}", Mem(itemsize=16, align=8)),
161
+ ("{x: int8, y: int64, pack=16}", Mem(itemsize=32, align=16)),
162
+
163
+ ("{x: uint16, y: {z: complex128}}", Mem(itemsize=24, align=8)),
164
+ ("{x: uint16, y: {z: complex128, align=16}}", Mem(itemsize=32, align=16)),
165
+ ("{x: uint16, y: {z: complex128}, align=16}", Mem(itemsize=32, align=16)),
166
+
167
+ # Primitive types
168
+ ("bool", Mem(itemsize=1, align=1)),
169
+
170
+ ("int8", Mem(itemsize=1, align=1)),
171
+ ("int16", Mem(itemsize=2, align=2)),
172
+ ("int32", Mem(itemsize=4, align=4)),
173
+ ("int64", Mem(itemsize=8, align=8)),
174
+
175
+ ("uint8", Mem(itemsize=1, align=1)),
176
+ ("uint16", Mem(itemsize=2, align=2)),
177
+ ("uint32", Mem(itemsize=4, align=4)),
178
+ ("uint64", Mem(itemsize=8, align=8)),
179
+
180
+ ("float32", Mem(itemsize=4, align=4)),
181
+ ("float64", Mem(itemsize=8, align=8)),
182
+
183
+ ("complex64", Mem(itemsize=8, align=4)),
184
+ ("complex128", Mem(itemsize=16, align=8)),
185
+
186
+ # Primitive optional types
187
+ ("?bool", Mem(itemsize=1, align=1)),
188
+
189
+ ("?int8", Mem(itemsize=1, align=1)),
190
+ ("?int16", Mem(itemsize=2, align=2)),
191
+ ("?int32", Mem(itemsize=4, align=4)),
192
+ ("?int64", Mem(itemsize=8, align=8)),
193
+
194
+ ("?uint8", Mem(itemsize=1, align=1)),
195
+ ("?uint16", Mem(itemsize=2, align=2)),
196
+ ("?uint32", Mem(itemsize=4, align=4)),
197
+ ("?uint64", Mem(itemsize=8, align=8)),
198
+
199
+ ("?float32", Mem(itemsize=4, align=4)),
200
+ ("?float64", Mem(itemsize=8, align=8)),
201
+
202
+ ("?complex64", Mem(itemsize=8, align=4)),
203
+ ("?complex128", Mem(itemsize=16, align=8)),
204
+
205
+ # References
206
+ ("&bool", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
207
+
208
+ ("&int8", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
209
+ ("&int16", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
210
+ ("&int32", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
211
+ ("&int64", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
212
+
213
+ ("ref(uint8)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
214
+ ("ref(uint16)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
215
+ ("ref(uint32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
216
+ ("ref(uint64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
217
+
218
+ ("ref(float32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
219
+ ("ref(float64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
220
+
221
+ ("ref(complex64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
222
+ ("ref(complex128)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
223
+
224
+ # Optional references
225
+ ("?&bool", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
226
+
227
+ ("?&int8", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
228
+ ("?&int16", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
229
+ ("?&int32", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
230
+ ("?&int64", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
231
+
232
+ ("?ref(uint8)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
233
+ ("?ref(uint16)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
234
+ ("?ref(uint32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
235
+ ("?ref(uint64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
236
+
237
+ ("?ref(float32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
238
+ ("?ref(float64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
239
+
240
+ ("?ref(complex64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
241
+ ("?ref(complex128)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
242
+
243
+ # References to optional types
244
+ ("&?bool", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
245
+
246
+ ("&?int8", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
247
+ ("&?int16", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
248
+ ("&?int32", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
249
+ ("&?int64", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
250
+
251
+ ("ref(?uint8)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
252
+ ("ref(?uint16)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
253
+ ("ref(?uint32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
254
+ ("ref(?uint64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
255
+
256
+ ("ref(?float32)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
257
+ ("ref(?float64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
258
+
259
+ ("ref(?complex64)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
260
+ ("ref(?complex128)", Mem(itemsize=SIZEOF_PTR, align=SIZEOF_PTR)),
261
+
262
+ # Constructors
263
+ ("Some(bool)", Mem(itemsize=1, align=1)),
264
+
265
+ ("Some(int8)", Mem(itemsize=1, align=1)),
266
+ ("Some(int16)", Mem(itemsize=2, align=2)),
267
+ ("Some(int32)", Mem(itemsize=4, align=4)),
268
+ ("Some(int64)", Mem(itemsize=8, align=8)),
269
+
270
+ ("Some(uint8)", Mem(itemsize=1, align=1)),
271
+ ("Some(uint16)", Mem(itemsize=2, align=2)),
272
+ ("Some(uint32)", Mem(itemsize=4, align=4)),
273
+ ("Some(uint64)", Mem(itemsize=8, align=8)),
274
+
275
+ ("Some(float32)", Mem(itemsize=4, align=4)),
276
+ ("Some(float64)", Mem(itemsize=8, align=8)),
277
+
278
+ ("Some(complex64)", Mem(itemsize=8, align=4)),
279
+ ("Some(complex128)", Mem(itemsize=16, align=8)),
280
+
281
+ # Optional constructors
282
+ ("?Some(bool)", Mem(itemsize=1, align=1)),
283
+
284
+ ("?Some(int8)", Mem(itemsize=1, align=1)),
285
+ ("?Some(int16)", Mem(itemsize=2, align=2)),
286
+ ("?Some(int32)", Mem(itemsize=4, align=4)),
287
+ ("?Some(int64)", Mem(itemsize=8, align=8)),
288
+
289
+ ("?Some(uint8)", Mem(itemsize=1, align=1)),
290
+ ("?Some(uint16)", Mem(itemsize=2, align=2)),
291
+ ("?Some(uint32)", Mem(itemsize=4, align=4)),
292
+ ("?Some(uint64)", Mem(itemsize=8, align=8)),
293
+
294
+ ("?Some(float32)", Mem(itemsize=4, align=4)),
295
+ ("?Some(float64)", Mem(itemsize=8, align=8)),
296
+
297
+ ("?Some(complex64)", Mem(itemsize=8, align=4)),
298
+ ("?Some(complex128)", Mem(itemsize=16, align=8)),
299
+
300
+ # Constructors containing optional types
301
+ ("Some(?bool)", Mem(itemsize=1, align=1)),
302
+
303
+ ("Some(?int8)", Mem(itemsize=1, align=1)),
304
+ ("Some(?int16)", Mem(itemsize=2, align=2)),
305
+ ("Some(?int32)", Mem(itemsize=4, align=4)),
306
+ ("Some(?int64)", Mem(itemsize=8, align=8)),
307
+
308
+ ("Some(?uint8)", Mem(itemsize=1, align=1)),
309
+ ("Some(?uint16)", Mem(itemsize=2, align=2)),
310
+ ("Some(?uint32)", Mem(itemsize=4, align=4)),
311
+ ("Some(?uint64)", Mem(itemsize=8, align=8)),
312
+
313
+ ("Some(?float32)", Mem(itemsize=4, align=4)),
314
+ ("Some(?float64)", Mem(itemsize=8, align=8)),
315
+
316
+ ("Some(?complex64)", Mem(itemsize=8, align=4)),
317
+ ("Some(?complex128)", Mem(itemsize=16, align=8)),
318
+ ]
319
+
320
+ # ======================================================================
321
+ # Broadcasting
322
+ # ======================================================================
323
+
324
+ def genindices(factor):
325
+ for i in range(4):
326
+ yield ()
327
+ for i in range(4):
328
+ yield (factor * i,)
329
+ for i in range(4):
330
+ for j in range(4):
331
+ yield (factor * i, factor * j)
332
+ for i in range(4):
333
+ for j in range(4):
334
+ for k in range(4):
335
+ yield (factor * i, factor * j, factor * k)
336
+
337
+ BROADCAST_TEST_CASES = [
338
+ ApplySpec(
339
+ flags = 'C|Fortran|Strided|Xnd',
340
+ sig = ndt("uint8 -> float64"),
341
+ in_types = [ndt("uint8")],
342
+ out_types = [ndt("float64")],
343
+ in_broadcast = [],
344
+ outer_dims = 0),
345
+
346
+ ApplySpec(
347
+ flags = 'Elemwise1D|C|Fortran|Strided|Xnd',
348
+ sig = ndt("... * uint8 -> ... * float64"),
349
+ in_types = [ndt("2 * uint8")],
350
+ out_types = [ndt("2 * float64")],
351
+ in_broadcast = [ndt("2 * uint8")],
352
+ outer_dims = 1),
353
+
354
+ ApplySpec(
355
+ flags = 'C|Fortran|Strided|Xnd',
356
+ sig = ndt("F[... * uint8] -> F[... * float64]"),
357
+ in_types = [ndt("!2 * 3 * uint8")],
358
+ out_types = [ndt("!2 * 3 * float64")],
359
+ in_broadcast = [ndt("!2 * 3 * uint8")],
360
+ outer_dims = 2),
361
+
362
+ ApplySpec(
363
+ flags = 'C|Fortran|Strided|Xnd',
364
+ sig = ndt("... * uint8 -> ... * float64"),
365
+ in_types = [ndt("fixed(shape=2, step=10) * uint8")],
366
+ out_types = [ndt("2 * float64")],
367
+ in_broadcast = [ndt("fixed(shape=2, step=10) * uint8")],
368
+ outer_dims = 1),
369
+
370
+ ApplySpec(
371
+ flags = 'Strided|Xnd',
372
+ sig = ndt("... * N * uint8 -> ... * N * float64"),
373
+ in_types = [ndt("fixed(shape=2, step=10) * uint8")],
374
+ out_types = [ndt("2 * float64")],
375
+ in_broadcast = [ndt("fixed(shape=2, step=10) * uint8")],
376
+ outer_dims = 0),
377
+
378
+ ApplySpec(
379
+ flags = 'C|Fortran|Strided|Xnd',
380
+ sig = ndt("... * N * uint8 -> ... * N * float64"),
381
+ in_types = [ndt("2 * 3 * uint8")],
382
+ out_types = [ndt("2 * 3 * float64")],
383
+ in_broadcast = [ndt("2 * 3 * uint8")],
384
+ outer_dims = 1),
385
+
386
+ ApplySpec(
387
+ flags = 'C|Strided|Xnd',
388
+ sig = ndt("... * N * M * uint8 -> ... * N * M * float64"),
389
+ in_types = [ndt("2 * 3 * uint8")],
390
+ out_types = [ndt("2 * 3 * float64")],
391
+ in_broadcast = [ndt("2 * 3 * uint8")],
392
+ outer_dims = 0),
393
+
394
+ ApplySpec(
395
+ flags = 'Xnd',
396
+ sig = ndt("N * D * float64 -> P * float64"),
397
+ in_types = [ndt("2 * 10 * float64")],
398
+ out_types = [ndt("P * float64")],
399
+ in_broadcast = [],
400
+ outer_dims = 0),
401
+
402
+ ApplySpec(
403
+ flags = 'C|Fortran|Xnd',
404
+ sig = ndt("var... * float64 -> var... * float64"),
405
+ in_types = [ndt("var(offsets=[0,2]) * var(offsets=[0,4,11]) * float64")],
406
+ out_types = [ndt("var(offsets=[0,2]) * var(offsets=[0,4,11]) * float64")],
407
+ in_broadcast = [],
408
+ outer_dims = 2)
409
+ ]