Skip to content

Commit 47c16e2

Browse files
committed
adopt series for serialization
1 parent 6d91eca commit 47c16e2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

source/mir/series.d

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module mir.series;
1818
import mir.ndslice.iterator: IotaIterator;
1919
import mir.ndslice.sorting: transitionIndex;
2020
import mir.qualifier;
21-
import mir.serde: serdeIgnore;
21+
import mir.serde: serdeIgnore, serdeFields, serdeKeys, serdeKeyOut;
2222
import std.traits;
2323
public import mir.ndslice.slice;
2424
public import mir.ndslice.sorting: sort;
@@ -260,6 +260,7 @@ Plain index series data structure.
260260
Index is assumed to be sorted.
261261
$(LREF sort) can be used to normalise a series.
262262
+/
263+
@serdeFields
263264
struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous)
264265
{
265266
private enum doUnittest = is(typeof(this) == mir_series!(int*, double*));
@@ -276,34 +277,25 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
276277
///
277278
@serdeIgnore enum SliceKind kind = kind_;
278279

279-
/++
280-
Data is any ndslice with only one constraints,
281-
`data` and `index` lengths should be equal.
282-
+/
283-
Slice!(Iterator, N, kind) data;
284-
285-
///
286-
@serdeIgnore IndexIterator _index;
287-
288280
/++
289281
Index series is assumed to be sorted.
290282
291283
`IndexIterator` is an iterator on top of date, date-time, time, or numbers or user defined types with defined `opCmp`.
292284
For example, `Date*`, `DateTime*`, `immutable(long)*`, `mir.ndslice.iterator.IotaIterator`.
293285
+/
294-
auto index()() @property @trusted
286+
auto index() @property @trusted
295287
{
296288
return _index.sliced(this.data._lengths[0]);
297289
}
298290

299291
/// ditto
300-
auto index()() @property @trusted const
292+
auto index() @property @trusted const
301293
{
302294
return _index.lightConst.sliced(this.data._lengths[0]);
303295
}
304296

305297
/// ditto
306-
auto index()() @property @trusted immutable
298+
auto index() @property @trusted immutable
307299
{
308300
return _index.lightImmutable.sliced(this.data._lengths[0]);
309301
}
@@ -312,11 +304,10 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
312304
void index()(Slice!IndexIterator index) @property @trusted
313305
{
314306
import core.lifetime: move;
315-
assert(index._lengths[0] == data._lengths[0]);
316307
this._index = move(index._iterator);
317308
}
318309

319-
///
310+
/// ditto
320311
static if (doUnittest)
321312
@safe version(mir_test) unittest
322313
{
@@ -327,8 +318,17 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
327318
assert(s.index == ["c", "d"]);
328319
}
329320

321+
/++
322+
Data is any ndslice with only one constraints,
323+
`data` and `index` lengths should be equal.
324+
+/
325+
Slice!(Iterator, N, kind) data;
326+
330327
@serdeIgnore:
331328

329+
///
330+
IndexIterator _index;
331+
332332
/// Index / Key / Time type aliases
333333
alias Index = typeof(typeof(this).init.index.front);
334334
/// Data / Value type aliases

0 commit comments

Comments
 (0)