<commit_before>#include "Locations.h"
#include "../Global.h"
#include "../Options.h"
#include "../Location.h"
#include "../Inputs/Input.h"
#include "../Data.h"
#include "../Location.h"

RegionLocations::RegionLocations(const Options& iOptions, const Data& iData) :
      Region(iOptions, iData),
      mDataset("") {
   if(iOptions.getValue("dataset", mDataset)) {
      Input* input = iData.getInput();
      assert(input != NULL);
      if(input == NULL) {
         std::stringstream ss;
         ss << "RegionLocations: Dataset " << mDataset << " does not exist";
         Global::logger->write(ss.str(), Logger::error);
      }
      mLocations = input->getLocations();
   }
   else {
      std::vector<float> lats;
      std::vector<float> lons;
      iOptions.getRequiredValues("lats", lats);
      iOptions.getRequiredValues("lons", lons);
      assert(lats.size() == lons.size());
      for(int i = 0; i < lats.size(); i++) {
         int id = i;
         float lat = lats[i];
         float lon = lons[i];
         std::string dataset = "";
         Location location(dataset, id, lat, lon);
         mLocations.push_back(location);
      }
   }
   if(mLocations.size() == 0) {
      std::stringstream ss;
      ss << "RegionLocations: No locations available";
      Global::logger->write(ss.str(), Logger::warning);
   }
   //Region::setSize(mLocations.size());
}

int RegionLocations::findCore(const Location& iLocation) const {
   if(iLocation.getDataset() == mDataset)
      return iLocation.getId();

   double minDist = Global::INF;
   int minI = Global::MV;
   for(int i = 0; i < mLocations.size(); i++) {
      double dist = mLocations[i].getDistance(iLocation);
      if(dist < minDist) {
         minDist = dist;
         minI = i;
      }
   }
   return minI;
}<commit_msg>Fixes specification of dataset in RegionLocation<commit_after>#include "Locations.h"
#include "../Global.h"
#include "../Options.h"
#include "../Location.h"
#include "../Inputs/Input.h"
#include "../Data.h"
#include "../Location.h"

RegionLocations::RegionLocations(const Options& iOptions, const Data& iData) :
      Region(iOptions, iData),
      mDataset("") {
   if(iOptions.hasValue("lats") || iOptions.hasValue("lons")) {
      std::vector<float> lats;
      std::vector<float> lons;
      //! Place parameters at latitude/longitude pairs
      iOptions.getValues("lats", lats);
      iOptions.getValues("lons", lons);
      if(lats.size() != lons.size()) {
         std::stringstream ss;
         std::string tag;
         iOptions.getValue("tag", tag);
         ss << "Region '" << tag << "' must have the same number of latitudes and longitudes specified";
         Global::logger->write(ss.str(), Logger::error);
      }
      for(int i = 0; i < lats.size(); i++) {
         int id = i;
         float lat = lats[i];
         float lon = lons[i];
         std::string dataset = "";
         Location location(dataset, id, lat, lon);
         mLocations.push_back(location);
      }
   }
   //! Use one parameter set for each location in this dataset
   else if(iOptions.getValue("dataset", mDataset)) {
      Input* input = iData.getInput(mDataset);
      assert(input != NULL);
      if(input == NULL) {
         std::stringstream ss;
         ss << "RegionLocations: Dataset " << mDataset << " does not exist";
         Global::logger->write(ss.str(), Logger::error);
      }
      mLocations = input->getLocations();
   }
   else {
      Input* input = iData.getObsInput();
      mDataset = input->getName();
      assert(input != NULL);
      mLocations = input->getLocations();
   }
   if(mLocations.size() == 0) {
      std::stringstream ss;
      ss << "RegionLocations: No locations available";
      Global::logger->write(ss.str(), Logger::warning);
   }
   //Region::setSize(mLocations.size());
}

int RegionLocations::findCore(const Location& iLocation) const {
   if(iLocation.getDataset() == mDataset)
      return iLocation.getId();

   double minDist = Global::INF;
   int minI = Global::MV;
   for(int i = 0; i < mLocations.size(); i++) {
      double dist = mLocations[i].getDistance(iLocation);
      if(dist < minDist) {
         minDist = dist;
         minI = i;
      }
   }
   return mLocations[minI].getId();
}
{'fraction_non_alphanumeric': 0.16403115411848004, 'fraction_numerical': 0.0014160962945480293, 'mean_word_length': 2.7175438596491226, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 16, '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': '6115761', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1328, 'n_words': 299}