code: def assign_constant(self, value, dtype=None):
          
          if not self.is_binarized():
              self.pianoroll[self.pianoroll.nonzero()] = value
              return
          if dtype is None:
              if isinstance(value, int):
                  dtype = int
              elif isinstance(value, float):
                  dtype = float
          nonzero = self.pianoroll.nonzero()
          self.pianoroll = np.zeros(self.pianoroll.shape, dtype)
          self.pianoroll[nonzero] = value
docs: Assign a constant value to all nonzeros in the pianoroll. If the
          pianoroll is not binarized, its data type will be preserved. If the
          pianoroll is binarized, it will be casted to the type of `value`.
  
          Arguments
          ---------
          value : int or float
              The constant value to be assigned to all the nonzeros in the
              pianoroll.