MarcSerraPeralta / iq_readout

Classifiers for IQ readout data from superconducting qubits
https://iq-readout.readthedocs.io/en/latest/
MIT License
1 stars 0 forks source link

Solve bug with np scalars in `to_yaml` #49

Closed MarcSerraPeralta closed 2 months ago

MarcSerraPeralta commented 2 months ago

The PR #48 fixed the problem with numpy arrays, however there was still a problem with numpy scalars, which is solved in this PR.

params:
  0:
    angle1: !!python/object/apply:numpy.core.multiarray.scalar
    - &id001 !!python/object/apply:numpy.dtype
      args:
      - f8
      - false
      - true
      state: !!python/tuple
      - 3
      - <
      - null
      - null
      - null
      - -1
      - -1
      - 0
    - !!binary |
      IlMFS2Q89j8=
    angle2: !!python/object/apply:numpy.core.multiarray.scalar
    - *id001
    - !!binary |
      yAt8HYAWwj8=

The implementation could not be done using np.integer and np.floating to check the instance of the objects because pyyaml works by identifying the first element of type(data).__mro__[0]. This corresponds to the bottom level of class (e.g. np.int64) and not to its higher levels (e.g. np.integer or np.generic).