<commit_before>import unittest

import blaze
from blaze import error, datashape
from blaze.tests import common
from blaze.datashape.parser import parse
from blaze.datashape.coretypes import Enum, Option, Function
from blaze.datashape.traits import integral

class TestDatashapeParser(common.BTestCase):

    def test_simple_parse(self):
        x = parse('2, 3, int32')
        y = parse('300 , 400, {x: int64; y: int32}')

        assert type(x) == datashape.DataShape
        assert type(y) == datashape.DataShape

        assert type(y[0]) == datashape.Fixed
        assert type(y[1]) == datashape.Fixed
        assert type(y[2]) == datashape.Record

        rec = y[-1]

        assert rec.fields['x'] == datashape.int64
        assert rec.fields['y'] == datashape.int32

    def test_compound_record1(self):
        p = parse('6, {x:int32; y:float64; z:string}')

        assert type(p[0]) == datashape.Fixed
        assert type(p[1]) == datashape.Record

    def test_compound_record2(self):
        p = parse('{ a: { x: int32; y: int32 }; b: {w: int32; u: int32 } }')

        assert type(p) == datashape.Record

    def test_free_variables(self):
        p = parse('N, M, 800, 600, int32')

        assert type(p[0]) == datashape.TypeVar
        assert type(p[1]) == datashape.TypeVar
        assert type(p[2]) == datashape.Fixed
        assert type(p[3]) == datashape.Fixed
        assert type(p[4]) == datashape.CType

    def test_parse_equality(self):
        x = parse('800, 600, int64')
        y = parse('800, 600, int64')

        assert x._equal(y)

    def test_parse_vars(self):
        x = parse('Range(1,2), int32')

        assert x[0].lower == 1
        assert x[0].upper == 2

    def test_constraints(self):
        x = parse('A, B : numeric')
        assert type(x.parameters[0]) == datashape.TypeVar
        assert type(x.parameters[1]) == datashape.Implements
        assert type(x.parameters[1].typeset == integral)

    def test_ellipsis(self):
        x = parse('..., T')
        assert type(x.parameters[0]) == datashape.Ellipsis
        assert type(x.parameters[1]) == datashape.TypeVar
        assert x.parameters[0].typevar is None

    def test_ellipsis2(self):
        x = parse('A..., T')
        assert type(x.parameters[0]) == datashape.Ellipsis
        assert type(x.parameters[1]) == datashape.TypeVar
        assert type(x.parameters[0].typevar) == datashape.TypeVar<commit_msg>Fix test to not use datashape._equal<commit_after>import unittest

import blaze
from blaze import error, datashape
from blaze.tests import common
from blaze.datashape.parser import parse
from blaze.datashape.coretypes import Enum, Option, Function
from blaze.datashape.traits import integral

class TestDatashapeParser(common.BTestCase):

    def test_simple_parse(self):
        x = parse('2, 3, int32')
        y = parse('300 , 400, {x: int64; y: int32}')

        assert type(x) == datashape.DataShape
        assert type(y) == datashape.DataShape

        assert type(y[0]) == datashape.Fixed
        assert type(y[1]) == datashape.Fixed
        assert type(y[2]) == datashape.Record

        rec = y[-1]

        assert rec.fields['x'] == datashape.int64
        assert rec.fields['y'] == datashape.int32

    def test_compound_record1(self):
        p = parse('6, {x:int32; y:float64; z:string}')

        assert type(p[0]) == datashape.Fixed
        assert type(p[1]) == datashape.Record

    def test_compound_record2(self):
        p = parse('{ a: { x: int32; y: int32 }; b: {w: int32; u: int32 } }')

        assert type(p) == datashape.Record

    def test_free_variables(self):
        p = parse('N, M, 800, 600, int32')

        assert type(p[0]) == datashape.TypeVar
        assert type(p[1]) == datashape.TypeVar
        assert type(p[2]) == datashape.Fixed
        assert type(p[3]) == datashape.Fixed
        assert type(p[4]) == datashape.CType

    def test_parse_equality(self):
        x = parse('800, 600, int64')
        y = parse('800, 600, int64')

        assert x == y

    def test_parse_vars(self):
        x = parse('Range(1,2), int32')

        assert x[0].lower == 1
        assert x[0].upper == 2

    def test_constraints(self):
        x = parse('A, B : numeric')
        assert type(x.parameters[0]) == datashape.TypeVar
        assert type(x.parameters[1]) == datashape.Implements
        assert type(x.parameters[1].typeset == integral)

    def test_ellipsis(self):
        x = parse('..., T')
        assert type(x.parameters[0]) == datashape.Ellipsis
        assert type(x.parameters[1]) == datashape.TypeVar
        assert x.parameters[0].typevar is None

    def test_ellipsis2(self):
        x = parse('A..., T')
        assert type(x.parameters[0]) == datashape.Ellipsis
        assert type(x.parameters[1]) == datashape.TypeVar
        assert type(x.parameters[0].typevar) == datashape.TypeVar
{'fraction_non_alphanumeric': 0.13991769547325103, 'fraction_numerical': 0.03539094650205761, 'mean_word_length': 2.722052067381317, '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': '4221007', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1604, 'n_words': 375}