<commit_before>import Encoding from '../Encoding';
import * as vlFieldDef from '../fielddef';
import {ROW, COL, X, Y} from '../channel';

export default function(encoding: Encoding, stats) {
  return {
    opacity: estimateOpacity(encoding, stats),
  };
};

function estimateOpacity(encoding,stats) {
  if (!stats) {
    return 1;
  }

  var numPoints = 0;

  if (encoding.isAggregate()) { // aggregate plot
    numPoints = 1;

    //  get number of points in each "cell"
    //  by calculating product of cardinality
    //  for each non faceting and non-ordinal X / Y fields
    //  note that ordinal x,y are not include since we can
    //  consider that ordinal x are subdividing the cell into subcells anyway
    encoding.forEach(function(fieldDef, channel) {

      if (channel !== ROW && channel !== COL &&
          !((channel === X || channel === Y) &&
          vlFieldDef.isOrdinalScale(fieldDef))
        ) {
        numPoints *= encoding.cardinality(channel, stats);
      }
    });

  } else { // raw plot

    // TODO: error handling
    if (!stats['*'])
      return 1;

    numPoints = stats['*'].max;  // count

    // small multiples divide number of points
    var numMultiples = 1;
    if (encoding.has(ROW)) {<commit_msg>style.ts<commit_after>import Encoding from '../Encoding';
import * as vlFieldDef from '../fielddef';
import {ROW, COL, X, Y, Channel} from '../channel';

export default function(encoding: Encoding, stats) {
  return {
    opacity: estimateOpacity(encoding, stats),
  };
};

function estimateOpacity(encoding,stats) {
  if (!stats) {
    return 1;
  }

  var numPoints = 0;

  if (encoding.isAggregate()) { // aggregate plot
    numPoints = 1;

    //  get number of points in each "cell"
    //  by calculating product of cardinality
    //  for each non faceting and non-ordinal X / Y fields
    //  note that ordinal x,y are not include since we can
    //  consider that ordinal x are subdividing the cell into subcells anyway
    encoding.forEach(function(fieldDef, channel: Channel) {

      if (channel !== ROW && channel !== COL &&
          !((channel === X || channel === Y) &&
          vlFieldDef.isOrdinalScale(fieldDef))
        ) {
        numPoints *= encoding.cardinality(channel, stats);
      }
    });

  } else { // raw plot

    // TODO: error handling
    if (!stats['*'])
      return 1;

    numPoints = stats['*'].max;  // count

    // small multiples divide number of points
    var numMultiples = 1;
    if (encoding.has(ROW)) {
{'fraction_non_alphanumeric': 0.13165266106442577, 'fraction_numerical': 0.004001600640256103, 'mean_word_length': 2.5919540229885056, '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': '5750666', 'n_tokens_mistral': 761, 'n_tokens_neox': 726, 'n_words': 244}