<commit_before>from copy import deepcopy
import math

class facet_grid(object):
    def __init__(self, x=None, y=None, scales=None):
        self.x = x
        self.y = y
        self.ncol = None
        self.nrow = None
        self.scales = scales

    def __radd__(self, gg):

        x = gg.data.get(self.x)
        y = gg.data.get(self.y)
        if x is None:
            n_dim_x = 1
        else:
            n_dim_x = x.nunique()
        if y is None:
            n_dim_y = 1
        else:
            n_dim_y = y.nunique()
        
        n_dim = n_dim_x * n_dim_y
        if self.ncol is None and self.nrow is None:
            n_wide = n_dim_x
            n_high = n_dim_y
        elif self.nrow is None:
            n_wide = self.ncol
            n_high = math.ceil(float(n_dim) / n_wide)
        elif self.ncol is None:
            n_high = self.nrow
            n_wide = math.ceil(float(n_dim) / n_high)
        else:
            n_wide = self.ncol
            n_high = self.nrow

        gg.n_wide, gg.n_high = int(n_wide), int(n_high)

        facets = []<commit_msg>Add error checks to facet_grid<commit_after>from copy import deepcopy
import math

class facet_grid(object):
    def __init__(self, x=None, y=None, scales=None):
        self.x = x
        self.y = y
        if self.x is None or self.y is None:
            raise Exception("facet_grid(): need both x and y mapping! Use facet_wrap() for only one dimension.")
        self.ncol = None
        self.nrow = None
        self.scales = scales

    def __radd__(self, gg):
        x = None
        y = None
        try:
            x = gg.data.get(self.x)
        except:
            raise Exception("facet_grid(): mapping for x (\"%s\") is not available in the DataFrame" % self.x)
        try:
            y = gg.data.get(self.y)
        except:
            raise Exception("facet_grid(): mapping for y (\"%s\") is not available in the DataFrame" % self.y)
        if x is None:
            n_dim_x = 1
        else:
            n_dim_x = x.nunique()
        if y is None:
            n_dim_y = 1
        else:
            n_dim_y = y.nunique()
        
        n_dim = n_dim_x * n_dim_y
        if self.ncol is None and self.nrow is None:
            n_wide = n_dim_x
            n_high = n_dim_y
        elif self.nrow is None:
            n_wide = self.ncol
            n_high = math.ceil(float(n_dim) / n_wide)
        elif self.ncol is None:
            n_high = self.nrow
            n_wide = math.ceil(float(n_dim) / n_high)
        else:
            n_wide = self.ncol
            n_high = self.nrow

        gg.n_wide, gg.n_high = int(n_wide), int(n_high)

        facets = []
{'fraction_non_alphanumeric': 0.09534534534534535, 'fraction_numerical': 0.0015015015015015015, 'mean_word_length': 1.4698795180722892, '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': '3680982', 'n_tokens_mistral': 930, 'n_tokens_neox': 912, 'n_words': 242}