6d27701311a5d0f013cf608dc5947e2fd0813882,hls4ml/model/hls_model.py,WeightVariable,update_precision,#WeightVariable#Any#,428

Before Change


        if "int" in self.type.precision:
            self.precision_fmt = "%d"
        else:
            match = re.search(".+<(.+?)>", self.type.precision)
            if match is not None:
                precision_bits = match.group(1).split(",")
                decimal_bits = int(precision_bits[0]) - int(precision_bits[1])
                decimal_spaces = int(np.floor(np.log10(2 ** decimal_bits - 1))) + 1

After Change


                if lsb < 1:
                    // Use str to represent the float with digits, get the length
                    // to right of decimal point
                    decimal_spaces = len(str(lsb).split(".")[1])
                else:
                    decimal_spaces = len(str(2**integer_bits)) 
                self.precision_fmt = "%.{}f".format(decimal_spaces)
            else:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: hls-fpga-machine-learning/hls4ml
Commit Name: 6d27701311a5d0f013cf608dc5947e2fd0813882
Time: 2020-05-04
Author: sioni.summers10@imperial.ac.uk
File Name: hls4ml/model/hls_model.py
Class Name: WeightVariable
Method Name: update_precision


Project Name: HazyResearch/fonduer
Commit Name: 0de3c091c75e36ffb4c12a2048110df37cafb644
Time: 2018-09-20
Author: lwhsiao@stanford.edu
File Name: src/fonduer/candidates/mentions.py
Class Name: Ngrams
Method Name: apply


Project Name: CellProfiler/CellProfiler
Commit Name: fe6d70a51d1a575313906708cf4bcda767b11d07
Time: 2010-09-20
Author: leek@1fc53939-2000-0410-845c-e8453a809027
File Name: cellprofiler/measurements.py
Class Name: Measurements
Method Name: apply_metadata