<commit_before>package latis.ops

import org.junit._
import org.junit.Assert._
import latis.dm._
import latis.time._
import latis.metadata.Metadata

class TestTimeTupleToTime {
  
  @Test
  def date_only = {
    val year = Text(Metadata("units" -> "yyyy"), "2015")
    val mon = Text(Metadata("units" -> "MM"), "11")
    val day = Text(Metadata("units" -> "dd"), "01")
    val ds = Dataset(Tuple(List(year, mon, day), Metadata("time"))) //Tuple must have name="time"
    val op = TimeTupleToTime()
    val ds2 = op(ds)
    ds2 match {
      case Dataset(t: Time) => assertEquals(1446336000000l, t.getJavaTime)
    }
  }
  
  @Test
  def date_and_time = {
    val year = Text(Metadata("units" -> "yyyy"), "1970")
    val mon  = Text(Metadata("units" -> "MM"), "1")
    val day  = Text(Metadata("units" -> "dd"), "01")
    val hour = Text(Metadata("units" -> "HH"), "0")
    val min  = Text(Metadata("units" -> "mm"), "0")
    val sec  = Text(Metadata("units" -> "ss"), "01")
    val ds = Dataset(Tuple(List(year, mon, day, hour, min, sec), Metadata("time")))
    val op = TimeTupleToTime()
    val ds2 = op(ds)
    ds2 match {
      case Dataset(t: Time) => assertEquals(1000l, t.getJavaTime)
    }
  }
}<commit_msg>test with time tuple in function domain<commit_after>package latis.ops

import org.junit._
import org.junit.Assert._
import latis.dm._
import latis.time._
import latis.metadata.Metadata

class TestTimeTupleToTime {
  
  @Test
  def date_only = {
    val year = Text(Metadata("units" -> "yyyy"), "2015")
    val mon = Text(Metadata("units" -> "MM"), "11")
    val day = Text(Metadata("units" -> "dd"), "01")
    val ds = Dataset(Tuple(List(year, mon, day), Metadata("time"))) //Tuple must have name="time"
    val op = TimeTupleToTime()
    val ds2 = op(ds)
    ds2 match {
      case Dataset(t: Time) => assertEquals(1446336000000l, t.getJavaTime)
    }
  }
  
  @Test
  def date_and_time = {
    val year = Text(Metadata("units" -> "yyyy"), "1970")
    val mon  = Text(Metadata("units" -> "MM"), "1")
    val day  = Text(Metadata("units" -> "dd"), "01")
    val hour = Text(Metadata("units" -> "HH"), "0")
    val min  = Text(Metadata("units" -> "mm"), "0")
    val sec  = Text(Metadata("units" -> "ss"), "01")
    val ds = Dataset(Tuple(List(year, mon, day, hour, min, sec), Metadata("time")))
    val op = TimeTupleToTime()
    val ds2 = op(ds)
    ds2 match {
      case Dataset(t: Time) => assertEquals(1000l, t.getJavaTime)
    }
  }
  
  @Test
  def in_function_domain = {
    val year = Text(Metadata("units" -> "yyyy"), "2015")
    val mon  = Text(Metadata("units" -> "MM"), "11")
    val day  = Text(Metadata("units" -> "dd"), "01")
    val time = Tuple(List(year, mon, day), Metadata("time"))
    val ds = Dataset(Function(List(Sample(time, Real(3.14)))))
    val op = TimeTupleToTime()
    val ds2 = op(ds)
    ds2 match {
      case Dataset(Function(it)) => it.next match {
        case Sample(t: Time, _) => assertEquals(1446336000000l, t.getJavaTime)
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.18, 'fraction_numerical': 0.035333333333333335, 'mean_word_length': 3.208976157082749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '524147', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1058, 'n_words': 271}