<commit_before>define [
  "underscore"
  "common/logging"
  "common/svg_colors"
], (_, Logging, svg_colors) ->

  logger = Logging.logger

  class Properties
    source_v_select: (attrname, datasource) ->
      glyph_props = @
      # if the attribute is not on this property object at all, log a bad request
      if not (attrname of glyph_props)
        logger.warn("requested vector selection of unknown property '#{attrname}' on objects")
        return (null for i in datasource.get_length())

      prop = glyph_props[attrname]
      # if the attribute specifies a field, and the field exists on
      # the column source, return the column from the column source
      if prop.field? and (prop.field of datasource.get('data'))
        return datasource.get_column(prop.field)
      else
        # If the user gave an explicit value, that should always be returned
        if glyph_props[attrname].value?
          default_value = glyph_props[attrname].value

        # otherwise, if the attribute exists on the object, return that value.
        # (This is a convenience case for when the object passed in has a member
        # that has the same name as the glyphspec name, e.g. an actual field
        # named "x" or "radius".)

        else if (attrname of datasource.get('data'))
          return datasource.get_column(attrname)

        # finally, check for a default value on this property object that could be returned
        else if glyph_props[attrname].default?
          default_value = glyph_props[attrname].default

        #FIXME this is where we could return a generator, which might
        #do a better job for constant propagation
        #for some reason a list comprehension fails here
        retval = []
        for i in [0...datasource.get_length()]
          retval.push(default_value)
        return retval

    _fix_singleton_array_value: (obj) ->
      # XXX: this is required because we can't distinguish between
      # cases like Text(text="field") and Text(test="actual text").
      if obj.value?
        value = obj.value

        if _.isArray(value)
          if value.length == 1
            return _.extend({}, obj, {value: value[0]})
          else
            throw new Error("expected an array of length 1, got #{value}")

      return obj

    string: (styleprovider, attrname) ->
      @[attrname] = {}

      value = styleprovider.mget(attrname)
      if not value?
        null<commit_msg>Remove obsolete logic from Properties.source_v_select()<commit_after>define [
  "underscore"
  "common/logging"
  "common/svg_colors"
], (_, Logging, svg_colors) ->

  logger = Logging.logger

  class Properties

    source_v_select: (attrname, datasource) ->
      obj = @[attrname]

      if not obj?
        throw new Error("requested vector selection of unknown property '#{attrname}'")
      else if obj.field? and (obj.field of datasource.get('data'))
        datasource.get_column(obj.field)
      else if _.isObject(obj)
        # FIXME: This is where we could return a generator, which might do a better
        # job for constant propagation for some reason a list comprehension fails here.
        # NOTE: obj.value can be undefined, because the owning property can be optional
        # like e.g. ImageUrl.w (yeah, meaningful name). Use NaN to indicate that we do
        # things on purpose. Not a great idea, but still seems better than carrying
        # undefineds or nulls around.
        value = if obj.value? then obj.value else NaN
        value for i in [0...datasource.get_length()]
      else
        throw new Error("requested vector selection of '#{attrname}' failed for #{obj}")

    _fix_singleton_array_value: (obj) ->
      # XXX: this is required because we can't distinguish between
      # cases like Text(text="field") and Text(test="actual text").
      if obj.value?
        value = obj.value

        if _.isArray(value)
          if value.length == 1
            return _.extend({}, obj, {value: value[0]})
          else
            throw new Error("expected an array of length 1, got #{value}")

      return obj

    string: (styleprovider, attrname) ->
      @[attrname] = {}

      value = styleprovider.mget(attrname)
      if not value?
        null
{'fraction_non_alphanumeric': 0.08906213087644696, 'fraction_numerical': 0.0018899125915426411, 'mean_word_length': 2.531276063386155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4254711', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1138, 'n_words': 439}