<commit_before>/* FILE function-generator.js */
//= require "component"
/*globals console sparks */

(function () {

  sparks.circuit.FunctionGenerator = function (props, breadBoard) {
    sparks.circuit.FunctionGenerator.parentConstructor.call(this, props, breadBoard);
    
    this.amplitudeScaleFactor = 1;
    
    // NOTE on validation of initialFrequency.
    //
    // If the initial frequency is not in the frequencies we request QUCS to simulate, we only find out after we call 
    // QUCS and get the simulation result back. It sounds like we're thereby missing an opportunity to validate
    // initialFrequency "up front" at object-creation time, but, really, we're not. From the perspective of an author 
    // who creates a JSON circuit spec with such an invalid initialFrequency, the validation failure only occurs when
    // the student (or author) actually runs the activity, whether the validation is done when the FunctionGenerator
    // is created, or whether it is done when QUCS returns. Doing validation at object creation time (below) would
    // require pre-calculating the frequency list which QUCS generates from a sweep spec.
    this.frequency = props.initialFrequency;
    
    // get an initial frequency from the frequency-range specification, if one exists
    if ( ('undefined' === typeof this.frequency || this.frequency === null) && props.frequencies ) {
      if ('number' === typeof props.frequencies[0]) {
        this.frequency = props.frequencies[0];
        this.possibleFrequencies = props.frequencies;
      }
      else if (props.frequencies[0] === 'linear' || props.frequencies[0] === 'logarithmic') {
        this.frequency = props.frequencies[1];
        this.possibleFrequencies = this._calcPossibleFrequencies(props);
      }
    }
    
    // set a base frequency, so that we don't have to change NetList representation after changing frequency
    this.baseFrequency = this.frequency;
    
    if ('undefined' === typeof this.frequency || this.frequency === null) {<commit_msg>Fix storing of possible frequencies in FG<commit_after>/* FILE function-generator.js */
//= require "component"
/*globals console sparks */

(function () {

  sparks.circuit.FunctionGenerator = function (props, breadBoard) {
    sparks.circuit.FunctionGenerator.parentConstructor.call(this, props, breadBoard);
    
    this.amplitudeScaleFactor = 1;
    
    // NOTE on validation of initialFrequency.
    //
    // If the initial frequency is not in the frequencies we request QUCS to simulate, we only find out after we call 
    // QUCS and get the simulation result back. It sounds like we're thereby missing an opportunity to validate
    // initialFrequency "up front" at object-creation time, but, really, we're not. From the perspective of an author 
    // who creates a JSON circuit spec with such an invalid initialFrequency, the validation failure only occurs when
    // the student (or author) actually runs the activity, whether the validation is done when the FunctionGenerator
    // is created, or whether it is done when QUCS returns. Doing validation at object creation time (below) would
    // require pre-calculating the frequency list which QUCS generates from a sweep spec.
    this.frequency = props.initialFrequency;
    
    // get an initial frequency from the frequency-range specification, if one exists
    if ( ('undefined' === typeof this.frequency || this.frequency === null) && props.frequencies ) {
      if ('number' === typeof props.frequencies[0]) {
        this.frequency = props.frequencies[0];
      }
      else if (props.frequencies[0] === 'linear' || props.frequencies[0] === 'logarithmic') {
        this.frequency = props.frequencies[1];
      }
    }
    
    // store (and generate, if nec.) the set of possible frequencies, so that the view can slide through these
    if (props.frequencies) {
      if ('number' === typeof props.frequencies[0]) {
        this.possibleFrequencies = props.frequencies;
      }
      else if (props.frequencies[0] === 'linear' || props.frequencies[0] === 'logarithmic') {
        this.possibleFrequencies = this._calcPossibleFrequencies(props);
      }
    }
    
    // set a base frequency, so that we don't have to change NetList representation after changing frequency
    this.baseFrequency = this.frequency;
    
    if ('undefined' === typeof this.frequency || this.frequency === null) {
{'fraction_non_alphanumeric': 0.09607976433265353, 'fraction_numerical': 0.003399048266485384, 'mean_word_length': 3.2606177606177607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6950291', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1122, 'n_words': 440}