<jupyter_start><jupyter_text>Managing mocks return value<jupyter_code># one reason to use mock is to control your codes behavior during tests
from datetime import datetime

def is_weekday():
    today = datetime.today()
    return 0 <= today.weekday() < 5

is_weekday()
from datetime import datetime
# Save a couple of test days
tuesday = datetime(year=2019, month=1, day=1)
saturday = datetime(year=2019, month=1, day=5)

# Mock datetime to control today's date
datetime = Mock()

def is_weekday2():
    today = datetime.today()
    # Python's datetime library treats Monday as 0 and Sunday as 6
    return (0 <= today.weekday() < 5)

datetime.today.return_value = tuesday
# Test Tuesday is a weekday
assert is_weekday2()
datetime.today.return_value = saturday
assert is_weekday2()
from collections import namedtuple
TEST_DIR = namedtuple("TEST_DIR", ["name", "entry.entryType"])
"""computes empirical bootstrap for regression problem
        Args:
        X:      coefficient matrix, (n_samples, p_features)
                n_samples is number of instances i.e rows
                p_features is number of features i.e columns

        y:      the response, shape = (n_samples,)
        n:      the size of the subsample, if None, then use length of data
        B:      the number of bootstrap
        model:  the regression model object
        """
        """returns the sample statistic from empirical bootstrap method
        Args:
        pop: the data from which we sample with replacement
                    shape = (n_samples,)
        n:        the size of the subsample, if None, then uses length of data
        B:        the number of bootstrap subsamples
        func:     the statistc we are interested

        Returns:
        bootstrapped estimate of the sample statistic
        """
x = (
    ("3" + "4"),
    ('test' + "test2")
)
x
manifold_stem = 'ego4d_fair'
manifold_path = 'tree/test'
y = tuple(manifold_path + manifold_stem + k for k in ['testA', 'testB', 'testC'])
x
y[:2] + x[:2]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08827856792545366, 'fraction_numerical': 0.013241785188818049, 'mean_word_length': 2.9080459770114944, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '380722', 'license': 'Apache-2.0', 'n_tokens_mistral': 620, 'n_tokens_neox': 576, 'n_words': 225, 'path': 'marketlearn/playground/practice.ipynb', 'repo_name': 'mrajancsr/QuantEquityManagement', 'size': '2039'}