def setUp(self) -> None:
     self.interval = HalfClosedIntervalLeft(2, 9)
     self.date_interval = HalfClosedIntervalLeft(datetime.date(2019, 2, 7),
                                                 datetime.date(2019, 2, 14))
     self.datetime_interval = HalfClosedIntervalLeft(
         datetime.datetime(2019, 2, 7, 11, 30),
         datetime.datetime(2019, 2, 7, 12, 30))
 def test_ge(self):
     self.assertTrue(self.interval >= HalfClosedIntervalLeft(2, 9))
     self.assertTrue(self.interval >= HalfClosedIntervalLeft(1, 9))
     self.assertFalse(self.interval >= HalfClosedIntervalLeft(3, 9))
 def test_gt(self):
     self.assertTrue(self.interval > HalfClosedIntervalLeft(2, 7))
     self.assertTrue(self.interval > HalfClosedIntervalLeft(1, 10))
     self.assertFalse(self.interval > HalfClosedIntervalLeft(2, 9))
 def test_ne(self):
     self.assertTrue(self.interval != HalfClosedIntervalLeft(2, 8))
     self.assertFalse(self.interval != HalfClosedIntervalLeft(2, 9))
 def test_lt(self):
     self.assertTrue(self.interval < HalfClosedIntervalLeft(2, 10))
     self.assertTrue(self.interval < HalfClosedIntervalLeft(3, 10))
     self.assertFalse(self.interval < HalfClosedIntervalLeft(2, 9))
Exemplo n.º 6
0
    parser = argparse.ArgumentParser(
        prog=__file__,
        description=
        'Generates csv files for dimension-averages exploration story')
    parser.add_argument('-input-datapath', type=str, required=True)
    parser.add_argument(
        '-story-datapath',
        type=str,
        required=True,
    )
    parser.add_argument('-partition-date',
                        type=str,
                        required=True,
                        help="partition-date (%Y%m%d) name of subfolder")
    parser.add_argument('-start-date',
                        type=str,
                        required=True,
                        help="%Y-%m-%d")
    parser.add_argument('-end-date', type=str, required=True, help="%Y-%m-%d")

    args = parser.parse_args()
    story_data_path = f"{args.story_datapath}/{args.partition_date}"
    source_data_path = f"{args.input_datapath}/{args.partition_date}"

    in_story_daterange = daterange_filter(
        "date", HalfClosedIntervalLeft(args.start_date, args.end_date))
    month_intervals_means_csvs(source_data_path, story_data_path,
                               in_story_daterange)
    month_intervals_pace_csv(f"{source_data_path}/workout-summary-run.csv",
                             story_data_path, in_story_daterange)
Exemplo n.º 7
0
        if weight in self._div_list[k]:
            return self._weight_classes[self._div_list[k]]

        if weight > self._div_list[k].upper_end:
            delta = -1
        else:
            delta = 1

        while True:
            k += delta
            if weight in self._div_list[k]:
                return self._weight_classes[self._div_list[k]]


boxing_weight_classes = {
    HalfClosedIntervalLeft(200, 750): ('Heavyweight', 200),  # technically unlimited upperbound
    HalfClosedIntervalLeft(175, 200): ('Cruiserweight', 175),
    HalfClosedIntervalLeft(168, 175): ('Light Heavyweight', 168),
    HalfClosedIntervalLeft(160, 168): ('Super Middleweight', 160),
    HalfClosedIntervalLeft(154, 160): ('Middleweight', 154),
    HalfClosedIntervalLeft(147, 154): ('Super Welterweight', 147),
    HalfClosedIntervalLeft(140, 147): ('Welterweight', 140),
    HalfClosedIntervalLeft(135, 140): ('Super Lightweight', 135),
    HalfClosedIntervalLeft(130, 135): ('Lightweight', 130),
    HalfClosedIntervalLeft(126, 130): ('Super Featherweight', 130),
    HalfClosedIntervalLeft(122, 130): ('Featherweight', 122),
    HalfClosedIntervalLeft(118, 122): ('Super Bantamweight', 118),
    HalfClosedIntervalLeft(115, 118): ('Bantamweight', 115),
    HalfClosedIntervalLeft(112, 115): ('Super Flyweight', 112),
    HalfClosedIntervalLeft(108, 112): ('Flyweight', 108)
}
Exemplo n.º 8
0
 def test_Interval_gt_exception(self):
     with self.assertRaises(TypeError):
         k = HalfClosedIntervalLeft(2, 9)
         j = ClosedInterval(2, 9)
         k > j
Exemplo n.º 9
0
 def test_Interval_values_exception(self):
     with self.assertRaises(ValueError):
         HalfClosedIntervalLeft(9, 2)
Exemplo n.º 10
0
 def test_Interval_types_mismatch(self):
     with self.assertRaises(TypeError):
         HalfClosedIntervalLeft(1, 'a')