@@ -204,13 +204,11 @@ struct mir_observation(Index, Data)
204204{
205205 // / Date, date-time, time, or index.
206206 Index index;
207- // / An alias for time-series index.
208- deprecated (" use `index` instead" ) alias time = index;
209- // / An alias for key-value representation.
210- deprecated (" use `index` instead" ) alias key = index;
211207 // / Value or ndslice.
212208 Data data;
213- // / An alias for key-value representation.
209+ @serdeIgnore:
210+ deprecated (" use `index` instead" ) alias time = index;
211+ deprecated (" use `index` instead" ) alias key = index;
214212 deprecated (" use `data` instead" ) alias value = data;
215213}
216214
@@ -264,7 +262,7 @@ $(LREF sort) can be used to normalise a series.
264262+/
265263struct mir_series (IndexIterator_, Iterator_, size_t N_ = 1 , SliceKind kind_ = Contiguous)
266264{
267- private enum doUnittest = is (typeof (this ) == Series ! (int * , double * ));
265+ private enum doUnittest = is (typeof (this ) == mir_series ! (int * , double * ));
268266
269267 // /
270268 alias IndexIterator = IndexIterator_;
@@ -273,10 +271,10 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
273271 alias Iterator = Iterator_;
274272
275273 // /
276- enum size_t N = N_ ;
274+ @serdeIgnore enum size_t N = N_ ;
277275
278276 // /
279- enum SliceKind kind = kind_;
277+ @serdeIgnore enum SliceKind kind = kind_;
280278
281279 /+ +
282280 Data is any ndslice with only one constraints,
@@ -285,24 +283,63 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
285283 Slice! (Iterator, N, kind) data;
286284
287285 // /
288- IndexIterator _index;
286+ @serdeIgnore IndexIterator _index;
287+
288+ /+ +
289+ Index series is assumed to be sorted.
290+
291+ `IndexIterator` is an iterator on top of date, date-time, time, or numbers or user defined types with defined `opCmp`.
292+ For example, `Date*`, `DateTime*`, `immutable(long)*`, `mir.ndslice.iterator.IotaIterator`.
293+ +/
294+ auto index ()() @property @trusted
295+ {
296+ return _index.sliced(this .data._lengths[0 ]);
297+ }
289298
290- // / Index / Key / Time type aliases
291- alias Index = typeof (typeof (this ).init.index.front);
292299 // / ditto
293- deprecated (" use `Index` instead" ) alias Key = Index;
300+ auto index ()() @property @trusted const
301+ {
302+ return _index.lightConst.sliced(this .data._lengths[0 ]);
303+ }
304+
294305 // / ditto
295- deprecated (" use `Index` instead" ) alias Time = Index;
306+ auto index ()() @property @trusted immutable
307+ {
308+ return _index.lightImmutable.sliced(this .data._lengths[0 ]);
309+ }
310+
311+ // / ditto
312+ void index ()(Slice! IndexIterator index) @property @trusted
313+ {
314+ import core.lifetime : move;
315+ assert (index._lengths[0 ] == data._lengths[0 ]);
316+ this ._index = move(index._iterator);
317+ }
318+
319+ // /
320+ static if (doUnittest)
321+ unittest
322+ {
323+ import mir.ndslice.slice: sliced;
324+ auto s = [" a" , " b" ].series([5 , 6 ]);
325+ assert (s.index == [" a" , " b" ]);
326+ s.index = [" c" , " d" ].sliced;
327+ assert (s.index == [" c" , " d" ]);
328+ }
329+
330+ @serdeIgnore:
331+
332+ // / Index / Key / Time type aliases
333+ alias Index = typeof (typeof (this ).init.index.front);
296334 // / Data / Value type aliases
297335 alias Data = typeof (typeof (this ).init.data.front);
298- // / ditto
336+
337+ deprecated (" use `Index` instead" ) alias Key = Index;
338+ deprecated (" use `Index` instead" ) alias Time = Index;
299339 deprecated (" use `Data` instead" ) alias Value = Data;
300340
301- // / An alias for time-series index.
302341 deprecated (" use `index` instead" ) alias time = index;
303- // / An alias for key-value representation.
304342 deprecated (" use `index` instead" ) alias key = index;
305- // / An alias for key-value representation.
306343 deprecated (" use `data` instead" ) alias value = data;
307344
308345 private enum defaultMsg () = " Series " ~ Unqual! (this .Data).stringof ~ " [" ~ Unqual! (this .Index).stringof ~ " ]: Missing" ;
@@ -332,29 +369,6 @@ struct mir_series(IndexIterator_, Iterator_, size_t N_ = 1, SliceKind kind_ = Co
332369 return this .lightScopeIndex == rhs.lightScopeIndex && this .data.lightScope == rhs.data.lightScope;
333370 }
334371
335- /+ +
336- Index series is assumed to be sorted.
337-
338- `IndexIterator` is an iterator on top of date, date-time, time, or numbers or user defined types with defined `opCmp`.
339- For example, `Date*`, `DateTime*`, `immutable(long)*`, `mir.ndslice.iterator.IotaIterator`.
340- +/
341- auto index ()() @property @trusted
342- {
343- return _index.sliced(this .data._lengths[0 ]);
344- }
345-
346- // / ditto
347- auto index ()() @property @trusted const
348- {
349- return _index.lightConst.sliced(this .data._lengths[0 ]);
350- }
351-
352- // / ditto
353- auto index ()() @property @trusted immutable
354- {
355- return _index.lightImmutable.sliced(this .data._lengths[0 ]);
356- }
357-
358372 private auto lightScopeIndex ()() @property @trusted
359373 {
360374 return .lightScope(_index).sliced(this .data._lengths[0 ]);
0 commit comments