<commit_before>from __future__ import print_function, division
import pandas as pd
import pytz
from datetime import timedelta
from copy import deepcopy
from warnings import warn

class TimeFrame(object):
    """A TimeFrame is a single time span or period,
    e.g. from "2013" to "2014".

    Attributes
    ----------
    _start : pd.Timestamp or None
        if None and empty if False
        then behave as if start is infinitely far into the past
    _end : pd.Timestamp or None
        if None and empty is False 
        then behave as if end is infinitely far into the future
    enabled : boolean
        If False then behave as if both _end and _start are None
    _empty : boolean
        If True then represents an empty time frame
    include_end : boolean
    """

    def __init__(self, start=None, end=None):
        self.clear()
        if isinstance(start, TimeFrame):
            self.copy_constructor(start)
        else:
            self.start = start
            self.end = end
            self.include_end = False

    def copy_constructor(self, other):
        for key, value in other.__dict__.iteritems():
            setattr(self, key, value)

    def clear(self):
        self.enabled = True
        self._start = None
        self._end = None
        self._empty = False

    @classmethod
    def from_dict(cls, d):
        def key_to_timestamp(key):
            string = d.get(key)
            return None if string is None else pd.Timestamp(string)
        start = key_to_timestamp('start')
        end = key_to_timestamp('end')
        return cls(start, end)

    @property
    def start(self):
        if self.enabled:
            return self._start<commit_msg>TimeZone constructor now accepts a 'tz' argument.<commit_after>from __future__ import print_function, division
import pandas as pd
import pytz
from datetime import timedelta
from copy import deepcopy
from warnings import warn

class TimeFrame(object):
    """A TimeFrame is a single time span or period,
    e.g. from "2013" to "2014".

    Attributes
    ----------
    _start : pd.Timestamp or None
        if None and empty if False
        then behave as if start is infinitely far into the past
    _end : pd.Timestamp or None
        if None and empty is False 
        then behave as if end is infinitely far into the future
    enabled : boolean
        If False then behave as if both _end and _start are None
    _empty : boolean
        If True then represents an empty time frame
    include_end : boolean
    """

    def __init__(self, start=None, end=None, tz=None):
        self.clear()
        if isinstance(start, TimeFrame):
            self.copy_constructor(start)
        else:
            self.start = start
            self.end = end
            self.include_end = False
            if tz is not None:
                if self._start:
                    self._start = self._start.tz_localize(tz)
                if self._end:
                    self._end = self._end.tz_localize(tz)

    def copy_constructor(self, other):
        for key, value in other.__dict__.iteritems():
            setattr(self, key, value)

    def clear(self):
        self.enabled = True
        self._start = None
        self._end = None
        self._empty = False

    @classmethod
    def from_dict(cls, d):
        def key_to_timestamp(key):
            string = d.get(key)
            return None if string is None else pd.Timestamp(string)
        start = key_to_timestamp('start')
        end = key_to_timestamp('end')
        return cls(start, end)

    @property
    def start(self):
        if self.enabled:
            return self._start
{'fraction_non_alphanumeric': 0.0729967069154775, 'fraction_numerical': 0.0043907793633369925, 'mean_word_length': 2.0223880597014925, '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': '7178369', 'n_tokens_mistral': 1002, 'n_tokens_neox': 961, 'n_words': 369}