<commit_before>#! /usr/bin/env python

import os

import datajoint as dj
import numpy as np


schema_in = dj.schema('test_blob_bypass_in')
schema_out = dj.schema('test_blob_bypass_out')

schema_in.drop(force=True)
schema_out.drop(force=True)

schema_in = dj.schema('test_blob_bypass_in')
schema_out = dj.schema('test_blob_bypass_out')

tst_dat = np.array([1, 2, 3])  # test blob; TODO: more complex example


@schema_in
class InputTable(dj.Lookup):
    definition = """
    id:                 int
    ---
    data:               blob
    """
    contents = [(0, tst_dat)]


@schema_out
class OutputTable(dj.Manual):
    definition = """
    id:                 int
    ---
    data:               blob
    """



def test_blob_bypass():
    dj.config['blob.encode_bypass'] = True
    OutputTable.insert(InputTable.fetch(as_dict=True))
    dj.config['blob.encode_bypass'] = False

    ins = InputTable.fetch(as_dict=True)
    outs = OutputTable.fetch(as_dict=True)

    assert((i[0]['data'] == tst_dat and i[0]['data'] == i[1]['data'])
           for i in zip(ins, outs))

    schema_in.drop(force=True)
    schema_out.drop(force=True)
<commit_msg>tests/test_blob_bypass.py: remove schema drops, variable renames per feedback<commit_after>#! /usr/bin/env python

import os

import datajoint as dj
import numpy as np


schema_in = dj.schema('test_blob_bypass_in')
schema_out = dj.schema('test_blob_bypass_out')

tst_blob = np.array([1, 2, 3])  # test blob;


@schema_in
class InputTable(dj.Lookup):
    definition = """
    id:                 int
    ---
    data:               blob
    """
    contents = [(0, tst_blob)]


@schema_out
class OutputTable(dj.Manual):
    definition = """
    id:                 int
    ---
    data:               blob
    """



def test_blob_bypass():
    dj.config['blob.encode_bypass'] = True
    OutputTable.insert(InputTable.fetch(as_dict=True))
    dj.config['blob.encode_bypass'] = False

    ins = InputTable.fetch(as_dict=True)
    outs = OutputTable.fetch(as_dict=True)

    assert((i[0]['data'] == tst_dat and i[0]['data'] == i[1]['data'])
           for i in zip(ins, outs))

    schema_in.drop(force=True)
    schema_out.drop(force=True)

{'fraction_non_alphanumeric': 0.1404391582799634, 'fraction_numerical': 0.006404391582799634, 'mean_word_length': 2.836842105263158, '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': '5078099', 'n_tokens_mistral': 791, 'n_tokens_neox': 760, 'n_words': 147}