liberty-db 0.8.3

A fully defined liberty data structure, efficient parser & formatter
Documentation
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
//! All item structure inside
//! `Timing`.
#![allow(clippy::multiple_inherent_impl)]
use core::ops::{Add, Mul, Not as _, Sub};

use crate::{
  ast::{
    self, fmt_comment_liberty, BuilderScope, GroupComments, GroupFn, ParseScope,
    ParsingBuilder, SimpleAttri,
  },
  common::{
    f64_into_hash_ord_fn,
    table::{DisplayTableLookUp, DisplayValues, TableLookUp},
  },
  expression::logic,
  ArcStr, Ctx,
};

use itertools::izip;
use strum_macros::{Display, EnumString};
/// The `timing_sense` attribute describes the way an input pin logically affects an output pin.
///
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =213.11
/// &end
/// =214.6
/// ">Reference-Definition</a>
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =203.55
/// &end
/// =203.55
/// ">Reference-Instance</a>
///
/// #### Syntax
/// `timing_sense : positive_unate | negative_unate | non_unate ;`
///
/// `positive_unate`: Combines incoming rise delays with local rise delays and
/// compares incoming fall delays with local fall delays.
///
/// `negative_unate`: Combines incoming rise delays with local fall delays and
/// compares incoming fall delays with local rise delays.
///
/// `non_unate`: Combines local delays with the worst-case incoming delay value.
/// The non-unate timing sense represents a function whose output value change cannot
/// be determined from the direction of the change in the input value.
///
/// Timing sense is derived from the logic function of a pin. For example, the value derived for
/// an AND gate is `positive_unate`, the value for a NAND gate is `negative_unate`, and the value
/// for an XOR gate is `non_unate`.
///
/// A function is said to be unate if a rising (falling) change on a positive (negative) unate
/// input variable causes the output function variable to rise (fall) or not change.
/// For a non-unate variable, further state information is required to determine the effects of
/// a particular state transition.
///
/// You can specify half-unate sequential timing arcs if the `timing_type` value is either
/// `rising_edge` or `falling_edge` and the `timing_sense` value is either `positive_unate`
/// or `negative_unate`.
/// + In the case of `rising_edge` and `positive_unate` values, only the `cell_rise` and `rise_transition` information is required.
/// + In the case of `rising_edge` and `negative_unate` values, only the `cell_fall` and `fall_transition` information is required.
/// + In the case of `falling_edge` and `positive_unate` values, only the `cell_rise` and `rise_transition` information is required.
/// + In the case of `falling_edge` and `negative_unate` values, only the `cell_fall` and `fall_transition` information is required.
///
/// Do not define the `timing_sense` value of a pin, except when you need to override the derived value
/// or when you are characterizing a noncombinational gate such as a three-state component. For example,
/// you might want to define the timing sense manually when you model multiple paths between
/// an input pin and an output pin, such as in an XOR gate.
///
/// It is possible that one path is positive unate while another is negative unate. In this case,
/// the first timing arc is given a `positive_unate` designation and the second is given a `negative_unate`
/// designation.
///
/// Timing arcs with a timing type of `clear` or `preset` require a `timing_sense` attribute.
/// If `related_pin` is an output pin, you must define a `timing_sense` attribute for that pin.
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =213.11
/// &end
/// =214.6
/// ">Reference-Definition</a>
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =203.55
/// &end
/// =203.55
/// ">Reference-Instance</a>
#[derive(
  Debug, Clone, Copy, PartialEq, Display, EnumString, Default, Hash, Eq, PartialOrd, Ord
)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum TimingSenseType {
  /// Combines incoming `rise` delays with local `rise` delays
  /// and compares incoming `fall` delays with local `fall` delays.
  /// <a name ="reference_link" href="
  /// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
  /// ?field=test
  /// &bgn
  /// =t.m0.x45.ha.y2b10.ffc.fs2.fc2.sc0.ls0.ws0
  /// &end
  /// =t.m0.x37.h4.y2b12.ff1.fs2.fc2.sc0.ls0.ws0
  /// ">Reference</a>
  #[strum(serialize = "positive_unate")]
  PositiveUnate,
  /// Combines incoming `rise` delays with local `fall` delays
  /// and compares incoming `fall` delays with local `rise` delays.
  /// <a name ="reference_link" href="
  /// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
  /// ?field=test
  /// &bgn
  /// =t.m0.x45.ha.y2b13.ffc.fs2.fc2.sc0.ls0.ws0
  /// &end
  /// =t.m0.x37.h4.y2b15.ff1.fs2.fc2.sc0.ls0.ws0
  /// ">Reference</a>
  #[strum(serialize = "negative_unate")]
  NegativeUnate,
  /// Combines local delays with the `worst-case` incoming delay value.
  /// The non-unate timing sense represents a function whose
  /// output value change cannot be determined from the direction
  /// of the change in the input value.
  /// <a name ="reference_link" href="
  /// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
  /// ?field=test
  /// &bgn
  /// =t.m0.x45.ha.y2b16.ffc.fs2.fc2.sc0.ls0.ws0
  /// &end
  /// =t.m0.x37.h4.y2b19.ff1.fs2.fc2.sc0.ls0.ws0
  /// ">Reference</a>
  #[strum(serialize = "non_unate")]
  #[default]
  NonUnate,
}

impl TimingSenseType {
  #[must_use]
  #[inline]
  pub fn compute_edge(&self, pin_edge: &logic::Edge) -> Option<logic::Edge> {
    match self {
      Self::PositiveUnate => Some(*pin_edge),
      Self::NegativeUnate => Some(pin_edge.not()),
      Self::NonUnate => None,
    }
  }
}
crate::ast::impl_self_builder!(TimingSenseType);
impl SimpleAttri for TimingSenseType {
  #[inline]
  fn nom_parse<'a>(i: &'a str, scope: &mut ParseScope) -> ast::SimpleParseRes<'a, Self> {
    ast::nom_parse_from_str(i, scope)
  }
}
/// You define the mode attribute within a timing group.
///
/// A mode attribute pertains to an individual timing arc.
/// The timing arc is active when mode is instantiated with a name and a value.
/// You can specify multiple instances of the mode attribute,
/// but only one instance for each timing arc.
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =219.39
/// +220.11
/// &end
/// =220.9
/// +222.73
/// ">Reference-Definition</a>
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
/// &bgn
/// =204.5
/// &end
/// =204.5
/// ">Reference-Instance</a>
///
// #[derive(Debug, Clone, Copy, Default)]
pub type Mode = [ArcStr; 2];

/// The `cell_degradation`  group describes a cell performance degradation
/// design rule for compiling a design.
///
/// A cell degradation design rule specifies the maximum capacitive load
/// a cell can drive without causing cell performance degradation during the fall transition.
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=347.33&end=347.35
/// ">Reference</a>
///
#[mut_set::derive::item(sort)]
#[derive(Debug, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
pub struct CellDegradation<C: Ctx> {
  /// name
  #[size = 8]
  #[liberty(name)]
  #[id(borrow = "&str", with_ref = false)]
  pub name: ArcStr,
  /// group comments
  #[size = 32]
  #[liberty(comments)]
  comments: GroupComments,
  #[size = 0]
  #[liberty(extra_ctx)]
  pub extra_ctx: C::Other,
  /// group undefined attributes
  #[size = 40]
  #[liberty(attributes)]
  pub attributes: ast::Attributes,
  /// /* lookup table */
  /// <a name ="reference_link" href="
  /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=348.6&end=348.7
  /// ">Reference</a>
  #[size = 24]
  #[liberty(complex)]
  pub index_1: Vec<f64>,
  /// /* lookup table */
  /// <a name ="reference_link" href="
  /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=348.6&end=348.7
  /// ">Reference</a>
  #[size = 24]
  #[liberty(complex)]
  pub values: Vec<f64>,
}
impl<C: Ctx> GroupFn for CellDegradation<C> {}

#[derive(Debug, Clone, Default)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TimingTableLookUp<C: Ctx> {
  pub extra_ctx: C::Table,
  pub name: Option<ArcStr>,
  pub comments: String,
  pub index_1: Vec<f64>,
  pub index_2: Vec<f64>,
  pub size1: usize,
  pub size2: usize,
  pub values: Vec<f64>,
  pub lvf_values: Vec<LVFValue>,
}
#[expect(
  clippy::similar_names,
  clippy::indexing_slicing,
  clippy::arithmetic_side_effects
)]
impl<C: Ctx> TimingTableLookUp<C> {
  #[inline]
  const fn find_pos(len: usize, pos: usize) -> Option<(usize, usize)> {
    if len <= 1 {
      None
    } else {
      Some(if pos == 0 {
        (0, 1)
      } else if pos == len {
        (len - 2, len - 1)
      } else {
        (pos - 1, pos)
      })
    }
  }
  #[inline]
  fn get_value(&self, ix: usize, iy: usize) -> f64 {
    self.values[ix * self.index_2.len() + iy]
  }
  #[inline]
  fn get_lvf_value(&self, ix: usize, iy: usize) -> LVFValue {
    self.lvf_values[ix * self.index_2.len() + iy]
  }
  #[must_use]
  #[inline]
  #[expect(clippy::float_arithmetic)]
  pub fn lookup(&self, idx1: &f64, idx2: &f64) -> Option<f64> {
    let idx1_ = f64_into_hash_ord_fn(idx1);
    let idx2_ = f64_into_hash_ord_fn(idx2);
    match self.index_1.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx1_)) {
      Ok(i1_) => {
        match self.index_2.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx2_)) {
          Ok(i_1) => Some(self.get_value(i1_, i_1)),
          Err(pos2) => Self::find_pos(self.index_2.len(), pos2).map(|(i_1, i_2)| {
            let q_1 = self.get_value(i1_, i_1);
            let q_2 = self.get_value(i1_, i_2);
            let x_1 = self.index_2[i_1];
            let x_2 = self.index_2[i_2];
            // q_1 + (q_2 - q_1) * ((idx2 - x_1) / (x_2 - x_1))
            (q_2 - q_1).mul_add((idx2 - x_1) / (x_2 - x_1), q_1)
          }),
        }
      }
      Err(pos1) => Self::find_pos(self.index_1.len(), pos1).and_then(|(i1_, i2_)| {
        let x1_ = self.index_1[i1_];
        let x2_ = self.index_1[i2_];
        match self.index_2.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx2_)) {
          Ok(i_1) => {
            let q1_ = self.get_value(i1_, i_1);
            let q2_ = self.get_value(i2_, i_1);
            // Some(q1_ + (q2_ - q1_) * ((idx1 - x1_) / (x2_ - x1_)))
            Some((q2_ - q1_).mul_add((idx1 - x1_) / (x2_ - x1_), q1_))
          }
          Err(pos2) => Self::find_pos(self.index_2.len(), pos2).map(|(i_1, i_2)| {
            let q11 = self.get_value(i1_, i_1);
            let q12 = self.get_value(i1_, i_2);
            let q21 = self.get_value(i2_, i_1);
            let q22 = self.get_value(i2_, i_2);
            let x_1 = self.index_2[i_1];
            let x_2 = self.index_2[i_2];
            // let q1_ = q11 + (q12 - q11) * ((idx2 - x_1) / (x_2 - x_1));
            let q1_ = (q12 - q11).mul_add((idx2 - x_1) / (x_2 - x_1), q11);
            // let q2_ = q21 + (q22 - q21) * ((idx2 - x_1) / (x_2 - x_1));
            let q2_ = (q22 - q21).mul_add((idx2 - x_1) / (x_2 - x_1), q21);
            // q1_ + (q2_ - q1_) * ((idx1 - x1_) / (x2_ - x1_))
            (q2_ - q1_).mul_add((idx1 - x1_) / (x2_ - x1_), q1_)
          }),
        }
      }),
    }
  }
  #[must_use]
  #[inline]
  #[expect(clippy::float_arithmetic)]
  pub fn lookup_lvf(&self, idx1: &f64, idx2: &f64) -> Option<LVFValue> {
    let idx1_ = f64_into_hash_ord_fn(idx1);
    let idx2_ = f64_into_hash_ord_fn(idx2);
    match self.index_1.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx1_)) {
      Ok(i1_) => {
        match self.index_2.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx2_)) {
          Ok(i_1) => Some(self.get_lvf_value(i1_, i_1)),
          Err(pos2) => Self::find_pos(self.index_2.len(), pos2).map(|(i_1, i_2)| {
            let q_1 = self.get_lvf_value(i1_, i_1);
            let q_2 = self.get_lvf_value(i1_, i_2);
            let x_1 = self.index_2[i_1];
            let x_2 = self.index_2[i_2];
            // q_1 + (q_2 - q_1) * ((idx2 - x_1) / (x_2 - x_1))
            (q_2 - q_1).mul_add((idx2 - x_1) / (x_2 - x_1), q_1)
          }),
        }
      }
      Err(pos1) => Self::find_pos(self.index_1.len(), pos1).and_then(|(i1_, i2_)| {
        let x1_ = self.index_1[i1_];
        let x2_ = self.index_1[i2_];
        match self.index_2.binary_search_by(|v| f64_into_hash_ord_fn(v).cmp(&idx2_)) {
          Ok(i_1) => {
            let q1_ = self.get_lvf_value(i1_, i_1);
            let q2_ = self.get_lvf_value(i2_, i_1);
            // Some(q1_ + (q2_ - q1_) * ((idx1 - x1_) / (x2_ - x1_)))
            Some((q2_ - q1_).mul_add((idx1 - x1_) / (x2_ - x1_), q1_))
          }
          Err(pos2) => Self::find_pos(self.index_2.len(), pos2).map(|(i_1, i_2)| {
            let q11 = self.get_lvf_value(i1_, i_1);
            let q12 = self.get_lvf_value(i1_, i_2);
            let q21 = self.get_lvf_value(i2_, i_1);
            let q22 = self.get_lvf_value(i2_, i_2);
            let x_1 = self.index_2[i_1];
            let x_2 = self.index_2[i_2];
            // let q1_ = q11 + (q12 - q11) * ((idx2 - x_1) / (x_2 - x_1));
            let q1_ = (q12 - q11).mul_add((idx2 - x_1) / (x_2 - x_1), q11);
            // let q2_ = q21 + (q22 - q21) * ((idx2 - x_1) / (x_2 - x_1));
            let q2_ = (q22 - q21).mul_add((idx2 - x_1) / (x_2 - x_1), q21);
            // q1_ + (q2_ - q1_) * ((idx1 - x1_) / (x2_ - x1_))
            (q2_ - q1_).mul_add((idx1 - x1_) / (x2_ - x1_), q1_)
          }),
        }
      }),
    }
  }
}

#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Debug, Default, Clone, Copy)]
pub struct LVFValue {
  /// `mean` = `nominal` + `mean_shift`
  pub mean: f64,
  pub std_dev: f64,
  pub skewness: f64,
}
impl LVFValue {
  #[inline]
  #[must_use]
  /// self * a + b
  pub fn mul_add(self, a: f64, b: Self) -> Self {
    Self {
      mean: self.mean.mul_add(a, b.mean),
      std_dev: self.std_dev.mul_add(a, b.std_dev),
      skewness: self.skewness.mul_add(a, b.skewness),
    }
  }
}
impl PartialEq for LVFValue {
  #[inline]
  fn eq(&self, other: &Self) -> bool {
    f64_into_hash_ord_fn(&self.mean) == f64_into_hash_ord_fn(&other.mean)
      && f64_into_hash_ord_fn(&self.std_dev) == f64_into_hash_ord_fn(&other.std_dev)
      && f64_into_hash_ord_fn(&self.skewness) == f64_into_hash_ord_fn(&other.skewness)
  }
}
#[expect(clippy::float_arithmetic)]
impl Add for LVFValue {
  type Output = Self;
  #[inline]
  fn add(self, rhs: Self) -> Self::Output {
    Self {
      mean: self.mean + rhs.mean,
      std_dev: self.std_dev + rhs.std_dev,
      skewness: self.skewness + rhs.skewness,
    }
  }
}
#[expect(clippy::float_arithmetic)]
impl Sub for LVFValue {
  type Output = Self;
  #[inline]
  /// TODO: check
  fn sub(self, rhs: Self) -> Self::Output {
    Self {
      mean: self.mean - rhs.mean,
      // TODO: check - or + ?
      std_dev: self.std_dev - rhs.std_dev,
      skewness: self.skewness - rhs.skewness,
    }
  }
}
#[expect(clippy::float_arithmetic)]
impl Mul<f64> for LVFValue {
  type Output = Self;
  #[inline]
  fn mul(self, rhs: f64) -> Self::Output {
    Self {
      mean: self.mean * rhs,
      std_dev: self.std_dev * rhs,
      skewness: self.skewness * rhs,
    }
  }
}

impl<C: Ctx> ParsingBuilder for Option<TimingTableLookUp<C>> {
  /// `value`, `mean_shift`, `std_dev`, `skewness`
  type Builder = (
    // value
    Option<<TableLookUp<C> as ParsingBuilder>::Builder>,
    // mean_shift
    Option<<TableLookUp<C> as ParsingBuilder>::Builder>,
    // std_dev
    Option<<TableLookUp<C> as ParsingBuilder>::Builder>,
    // skewness
    Option<<TableLookUp<C> as ParsingBuilder>::Builder>,
  );
  #[inline]
  #[expect(clippy::float_arithmetic)]
  fn build(builder: Self::Builder, _scope: &mut BuilderScope) -> Self {
    #[inline]
    fn eq_index<C: Ctx>(
      lhs: &<TableLookUp<C> as ParsingBuilder>::Builder,
      rhs: &<TableLookUp<C> as ParsingBuilder>::Builder,
    ) -> bool {
      lhs.index_1 == rhs.index_1 && lhs.index_2 == rhs.index_2
    }
    match builder {
      (Some(_value), Some(_mean_shift), Some(_std_dev), Some(_skewness)) => {
        let (lvf_values, comments) = if eq_index(&_value, &_mean_shift)
          && eq_index(&_mean_shift, &_std_dev)
          && eq_index(&_std_dev, &_skewness)
        {
          (
            izip!(
              _value.values.inner.iter(),
              _mean_shift.values.inner,
              _std_dev.values.inner,
              _skewness.values.inner
            )
            .map(|(value, mean_shift, std_dev, skewness)| {
              let mean = value + mean_shift;
              LVFValue { mean, std_dev, skewness }
            })
            .collect(),
            String::new(),
          )
        } else {
          log::error!("LVF LUTs' index mismatch");
          (Vec::new(), String::from("LVF LUTs' index mismatch"))
        };
        Some(TimingTableLookUp {
          name: _value.name,
          comments,
          index_1: _value.index_1,
          index_2: _value.index_2,
          size1: _value.values.size1,
          size2: _value.values.size2,
          values: _value.values.inner,
          lvf_values,
          extra_ctx: Default::default(),
        })
      }
      (Some(_value), None, None, None) => Some(TimingTableLookUp {
        name: _value.name,
        comments: String::new(),
        index_1: _value.index_1,
        index_2: _value.index_2,
        size1: _value.values.size1,
        size2: _value.values.size2,
        values: _value.values.inner,
        lvf_values: Vec::new(),
        extra_ctx: Default::default(),
      }),
      _ => None,
    }
  }
}
impl<C: Ctx> TimingTableLookUp<C> {
  #[inline]
  #[expect(clippy::float_arithmetic)]
  pub(crate) fn fmt_liberty<T: core::fmt::Write, I: ast::Indentation>(
    &self,
    key: &str,
    f: &mut ast::CodeFormatter<'_, T, I>,
  ) -> core::fmt::Result {
    fmt_comment_liberty(Some(&self.comments), f)?;
    DisplayTableLookUp {
      name: &self.name,
      index_1: &self.index_1,
      index_2: &self.index_2,
      values: DisplayValues {
        size1: self.size1,
        inner: self.values.iter().copied(),
      },
    }
    .fmt_self("", key, f)?;
    if !self.lvf_values.is_empty() {
      DisplayTableLookUp {
        name: &self.name,
        index_1: &self.index_1,
        index_2: &self.index_2,
        values: DisplayValues {
          size1: self.size1,
          inner: izip!(self.values.iter(), self.lvf_values.iter())
            .map(|(value, lvf)| lvf.mean - value),
        },
      }
      .fmt_self("ocv_mean_shift_", key, f)?;
      DisplayTableLookUp {
        name: &self.name,
        index_1: &self.index_1,
        index_2: &self.index_2,
        values: DisplayValues {
          size1: self.size1,
          inner: self.lvf_values.iter().map(|lvf| lvf.std_dev),
        },
      }
      .fmt_self("ocv_std_dev_", key, f)?;
      DisplayTableLookUp {
        name: &self.name,
        index_1: &self.index_1,
        index_2: &self.index_2,
        values: DisplayValues {
          size1: self.size1,
          inner: self.lvf_values.iter().map(|lvf| lvf.skewness),
        },
      }
      .fmt_self("ocv_skewness_", key, f)?;
    }
    Ok(())
  }
}