<commit_before>import { map, takeWhile, drop, range, sum } from 'lodash';
import React from 'react';
import Paper from 'material-ui/lib/paper';

import { PropTypes } from 'helpers/react';
const { string, number, shape, arrayOf, bool } = PropTypes;




function aspectRatio({ width, height }) {
  return width / height;
}

function balancedRow(imagePool, idealHeight, containerWidth) { //-- returns the images, and the scale needed for them to fit in the width
  const images = [...imagePool];

  let rowWidthAtIdealHeight = 0;
  const rowImages = takeWhile(images, (image) => {
    const imageAspectRatio = aspectRatio(image);
    const scaledImageWidth = idealHeight * imageAspectRatio;


    if (rowWidthAtIdealHeight < containerWidth) {
      rowWidthAtIdealHeight += scaledImageWidth;
      return true;
    }

    return false;
  });

  const rowAspectRatio = aspectRatio({ width: rowWidthAtIdealHeight, height: idealHeight });
  const rowHeightAtContainerWidth = containerWidth / rowAspectRatio;

  return {
    images: rowImages,
    height: images.length > 0 ? rowHeightAtContainerWidth : 0
  };
}

export default function SceneGrid({<commit_msg>if there aren't enough images to fill a row, just use the ideal height for the row and leave blank space<commit_after>import { map, takeWhile, drop, range, sum } from 'lodash';
import React from 'react';
import Paper from 'material-ui/lib/paper';

import { PropTypes } from 'helpers/react';
const { string, number, shape, arrayOf, bool } = PropTypes;




function aspectRatio({ width, height }) {
  return width / height;
}

function balancedRow(imagePool, idealHeight, containerWidth) { //-- returns the images, and the scale needed for them to fit in the width
  const images = [...imagePool];

  let rowWidthAtIdealHeight = 0;
  const rowImages = takeWhile(images, (image) => {
    const imageAspectRatio = aspectRatio(image);
    const scaledImageWidth = idealHeight * imageAspectRatio;


    if (rowWidthAtIdealHeight < containerWidth) {
      rowWidthAtIdealHeight += scaledImageWidth;
      return true;
    }

    return false;
  });

  if (!(rowWidthAtIdealHeight >= containerWidth)) {
    return {
      images: rowImages,
      height: idealHeight
    };
  }

  const rowAspectRatio = aspectRatio({ width: rowWidthAtIdealHeight, height: idealHeight });
  const rowHeightAtContainerWidth = containerWidth / rowAspectRatio;

  return {
    images: rowImages,
    height: images.length > 0 ? rowHeightAtContainerWidth : 0
  };
}

export default function SceneGrid({
{'fraction_non_alphanumeric': 0.09853581321725366, 'fraction_numerical': 0.002374356944994064, 'mean_word_length': 4.045908183632735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '2629147', 'n_tokens_mistral': 744, 'n_tokens_neox': 708, 'n_words': 229}