diff --git a/Jenkisfile b/Jenkisfile new file mode 100644 index 0000000..af57806 --- /dev/null +++ b/Jenkisfile @@ -0,0 +1,29 @@ +pipeline { + agent { + docker { + image 'research/python-qpython-env:99fb7f9cbe9720187984dc160e78742876bc9007' + } + } + stages { + stage('Build') { + steps { + echo ">> Building..." + } + } + stage('Test') { + steps { + sh 'tox' + } + post { + always { + junit 'test-reports/results.xml' + } + } + } + stage('Publish') { + steps { + echo ">> Publishing..." + } + } + } +} diff --git a/qpython/_pandas.py b/qpython/_pandas.py index 07e12a1..fa34afe 100644 --- a/qpython/_pandas.py +++ b/qpython/_pandas.py @@ -82,11 +82,11 @@ def _read_table(self, qtype = QTABLE): if isinstance(data[i], str): # convert character list (represented as string) to numpy representation meta[column_name] = QSTRING - odict[column_name] = pandas.Series(list(data[i]), dtype = numpy.str).replace(b' ', numpy.nan) + odict[column_name] = pandas.Series(list(data[i]), dtype = str).replace(b' ', numpy.nan) elif isinstance(data[i], bytes): # convert character list (represented as string) to numpy representation meta[column_name] = QSTRING - odict[column_name] = pandas.Series(list(data[i].decode()), dtype = numpy.str).replace(b' ', numpy.nan) + odict[column_name] = pandas.Series(list(data[i].decode()), dtype = str).replace(b' ', numpy.nan) elif isinstance(data[i], (list, tuple)): meta[column_name] = QGENERAL_LIST tarray = numpy.ndarray(shape = len(data[i]), dtype = numpy.dtype('O')) @@ -94,8 +94,12 @@ def _read_table(self, qtype = QTABLE): tarray[j] = data[i][j] odict[column_name] = tarray else: - meta[column_name] = data[i].meta.qtype - odict[column_name] = data[i] + meta[column_name] = data[i].meta.qtype + if data[i].meta.qtype in {abs(QSYMBOL)}: + odict[column_name] = data[i].map(lambda x: x.decode('UTF-8')) + else: + odict[column_name] = data[i] + df = pandas.DataFrame(odict) df.meta = meta diff --git a/qpython/fastutils.pyx b/qpython/fastutils.pyx index 5e462e4..e05b2f4 100644 --- a/qpython/fastutils.pyx +++ b/qpython/fastutils.pyx @@ -17,8 +17,8 @@ import numpy cimport numpy -DTYPE = numpy.int -ctypedef numpy.int_t DTYPE_t +DTYPE = numpy.uint +ctypedef numpy.uint DTYPE_t DTYPE8 = numpy.int ctypedef numpy.uint8_t DTYPE8_t diff --git a/qpython/qcollection.py b/qpython/qcollection.py index b9eb38e..cb3ec86 100644 --- a/qpython/qcollection.py +++ b/qpython/qcollection.py @@ -25,12 +25,14 @@ class QList(numpy.ndarray): def _meta_init(self, **meta): '''Initialises the meta-information.''' self.meta = MetaData(**meta) + + #This behaviour is different from ndarray which returns an array companring each element with the input + #This causes issues in pandas when it tries to create an array mask by using == + # def __eq__(self, other): + # return numpy.array_equal(self, other) - def __eq__(self, other): - return numpy.array_equal(self, other) - - def __ne__(self, other): - return not self.__eq__(other) + # def __ne__(self, other): + # return not self.__eq__(other) def __hash__(self): return hash((self.dtype, self.meta.qtype, self.tostring())) @@ -294,11 +296,12 @@ class QTable(numpy.recarray): def _meta_init(self, **meta): self.meta = MetaData(**meta) - def __eq__(self, other): - return numpy.array_equal(self, other) + #Behaviour different from recarray: returns a bool istead of array of same length + # def __eq__(self, other): + # return numpy.array_equal(self, other) - def __ne__(self, other): - return not self.__eq__(other) + # def __ne__(self, other): + # return not self.__eq__(other) def __array_finalize__(self, obj): self.meta = MetaData() if obj is None else getattr(obj, 'meta', MetaData()) @@ -437,7 +440,9 @@ def __str__(self, *args, **kwargs): return '%s!%s' % (self.keys, self.values) def __eq__(self, other): - return isinstance(other, QKeyedTable) and numpy.array_equal(self.keys, other.keys) and numpy.array_equal(self.values, other.values) + if not isinstance(other, QKeyedTable): + return False + return (self.keys == other.keys) & (self.values == other.values) def __ne__(self, other): return not self.__eq__(other) diff --git a/qpython/qconnection.py b/qpython/qconnection.py index c3054d8..3c97f27 100644 --- a/qpython/qconnection.py +++ b/qpython/qconnection.py @@ -65,6 +65,8 @@ class QConnection(object): - `encoding` (`string`) - string encoding for data deserialization - `reader_class` (subclass of `QReader`) - data deserializer - `writer_class` (subclass of `QWriter`) - data serializer + - `capacity_byte` (byte) - handshake capacity byte. Use it only if you + want to override the default. See https://code.kx.com/v2/basics/ipc/#handshake :Options: - `raw` (`boolean`) - if ``True`` returns raw data chunk instead of parsed data, **Default**: ``False`` @@ -78,11 +80,12 @@ class QConnection(object): ''' - def __init__(self, host, port, username = None, password = None, timeout = None, encoding = 'latin-1', reader_class = None, writer_class = None, **options): + def __init__(self, host, port, username = None, password = None, timeout = None, encoding = 'latin-1', reader_class = None, writer_class = None, capacity_byte = b'\3', **options): self.host = host self.port = port self.username = username self.password = password + self.capacity_byte = capacity_byte self._connection = None self._connection_file = None @@ -186,7 +189,7 @@ def _initialize(self): '''Performs a IPC protocol handshake.''' credentials = (self.username if self.username else '') + ':' + (self.password if self.password else '') credentials = credentials.encode(self._encoding) - self._connection.send(credentials + b'\3\0') + self._connection.send(credentials + self.capacity_byte + b'\0') response = self._connection.recv(1) if len(response) != 1: diff --git a/qpython/qreader.py b/qpython/qreader.py index 2dbdf54..367b50b 100644 --- a/qpython/qreader.py +++ b/qpython/qreader.py @@ -16,9 +16,9 @@ import struct import sys -if sys.version > '3': - from sys import intern - unicode = str + +from sys import intern +unicode = str from qpython import MetaData, CONVERSION_OPTIONS from qpython.qtype import * # @UnusedWildImport @@ -30,7 +30,7 @@ except: from qpython.utils import uncompress - +CHUNK_SIZE = 4096 class QReaderException(Exception): ''' @@ -167,7 +167,7 @@ def read_header(self, source = None): # skip 1 byte self._buffer.skip() - message_size = self._buffer.get_int() + message_size = self._buffer.get_size() return QMessage(None, message_type, message_size, message_compressed) @@ -197,14 +197,14 @@ def read_data(self, message_size, is_compressed = False, **options): if is_compressed: if self._stream: self._buffer.wrap(self._read_bytes(4)) - uncompressed_size = -8 + self._buffer.get_int() + uncompressed_size = -8 + self._buffer.get_size() compressed_data = self._read_bytes(message_size - 12) if self._stream else self._buffer.raw(message_size - 12) raw_data = numpy.frombuffer(compressed_data, dtype = numpy.uint8) if uncompressed_size <= 0: raise QReaderException('Error while data decompression.') - raw_data = uncompress(raw_data, numpy.intc(uncompressed_size)) + raw_data = uncompress(raw_data, numpy.uintc(uncompressed_size)) raw_data = numpy.ndarray.tostring(raw_data) self._buffer.wrap(raw_data) elif self._stream: @@ -243,7 +243,7 @@ def _read_error(self, qtype = QERROR): @parse(QSTRING) def _read_string(self, qtype = QSTRING): self._buffer.skip() # ignore attributes - length = self._buffer.get_int() + length = self._buffer.get_size() return self._buffer.raw(length) if length > 0 else b'' @@ -284,7 +284,7 @@ def _read_temporal(self, qtype): def _read_list(self, qtype): self._buffer.skip() # ignore attributes - length = self._buffer.get_int() + length = self._buffer.get_size() conversion = PY_TYPE.get(-qtype, None) if qtype == QSYMBOL_LIST: @@ -333,7 +333,7 @@ def _read_table(self, qtype = QTABLE): @parse(QGENERAL_LIST) def _read_general_list(self, qtype = QGENERAL_LIST): self._buffer.skip() # ignore attributes - length = self._buffer.get_int() + length = self._buffer.get_size() return [self._read_object() for x in range(length)] @@ -373,7 +373,7 @@ def _read_adverb_function(self, qtype = QADVERB_FUNC_106): @parse(QPROJECTION) def _read_projection(self, qtype = QPROJECTION): - length = self._buffer.get_int() + length = self._buffer.get_size() parameters = [ self._read_object() for x in range(length) ] return QProjection(parameters) @@ -384,13 +384,33 @@ def _read_bytes(self, length): if length == 0: return b'' - else: + elif length <= CHUNK_SIZE: data = self._stream.read(length) + else: + data = self._read_in_chunks(length) - if len(data) == 0: + if not data: raise QReaderException('Error while reading data') return data + def _read_in_chunks(self, length): + from io import StringIO ## for Python 3 + + # for large messages, read from the stream in chunks + remaining = length + buff = StringIO() + + while remaining > 0: + chunk = self._stream.read(min(remaining, CHUNK_SIZE)) + + if chunk: + remaining = remaining - len(chunk) + buff.write(chunk) + else: + break + + return buff.getvalue() + class BytesBuffer(object): @@ -499,6 +519,15 @@ def get_int(self): ''' return self.get('i') + + def get_size(self): + ''' + Gets a single 32-bit unsinged integer from the buffer. + + :returns: single unsigned integer + ''' + return self.get('I') + def get_symbol(self): ''' diff --git a/qpython/qwriter.py b/qpython/qwriter.py index d24fa5d..89d8e6e 100644 --- a/qpython/qwriter.py +++ b/qpython/qwriter.py @@ -162,10 +162,12 @@ def _write_string(self, data): if not self._options.single_char_strings and len(data) == 1: self._write_atom(ord(data), QCHAR) else: - self._buffer.write(struct.pack('=bxi', QSTRING, len(data))) if isinstance(data, str): - self._buffer.write(data.encode(self._encoding)) + encoded_data = data.encode(self._encoding) + self._buffer.write(struct.pack('=bxi', QSTRING, len(encoded_data))) + self._buffer.write(encoded_data) else: + self._buffer.write(struct.pack('=bxi', QSTRING, len(data))) self._buffer.write(data) diff --git a/qpython/utils.py b/qpython/utils.py index daebee3..7c9395c 100644 --- a/qpython/utils.py +++ b/qpython/utils.py @@ -18,19 +18,19 @@ def uncompress(data, uncompressed_size): - _0 = numpy.intc(0) - _1 = numpy.intc(1) - _2 = numpy.intc(2) - _128 = numpy.intc(128) - _255 = numpy.intc(255) + _0 = numpy.uintc(0) + _1 = numpy.uintc(1) + _2 = numpy.uintc(2) + _128 = numpy.uintc(128) + _255 = numpy.uintc(255) n, r, s, p = _0, _0, _0, _0 i, d = _1, _1 f = _255 & data[_0] - ptrs = numpy.zeros(256, dtype = numpy.intc) + ptrs = numpy.zeros(256, dtype = numpy.uintc) uncompressed = numpy.zeros(uncompressed_size, dtype = numpy.uint8) - idx = numpy.arange(uncompressed_size, dtype = numpy.intc) + idx = numpy.arange(uncompressed_size, dtype = numpy.uintc) while s < uncompressed_size: pp = p + _1 diff --git a/requirements.txt b/requirements.txt index e54f4a6..efa0669 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -pytest>=2.5.0 -numpy>=1.8.0 -pandas>=0.14.0 -cython>=0.20 -twisted>=13.2.0 -mock>=1.0.1 \ No newline at end of file +pytest>=3.6.0 +numpy>=1.20.0 +pandas>=1.3.0 +cython>=0.28 +twisted>=20.3.0 +mock>=4.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 08cf6b8..e14d5db 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ # limitations under the License. # -from distutils.core import setup +from setuptools import setup from qpython import __version__ import os @@ -71,13 +71,8 @@ def read(fname): 'Operating System :: POSIX', 'Operating System :: Unix', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', 'Topic :: Database :: Front-Ends', 'Topic :: Scientific/Engineering', 'Topic :: Software Development', diff --git a/tests/pandas_test.py b/tests/pandas_test.py index b39d533..df4aa58 100644 --- a/tests/pandas_test.py +++ b/tests/pandas_test.py @@ -16,6 +16,7 @@ import binascii import struct +import os import sys try: from cStringIO import BytesIO @@ -29,7 +30,7 @@ from qpython.qcollection import qlist, QList, QTemporalList, QDictionary from qpython.qtemporal import QTemporal - +TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'test_data') try: import pandas @@ -251,7 +252,7 @@ def init(): global BINARY BINARY = OrderedDict() - with open('tests/QExpressions3.out', 'rb') as f: + with open(os.path.join(TEST_DATA_DIR, 'QExpressions3.out'), 'rb') as f: while True: query = f.readline().strip() binary = f.readline().strip() diff --git a/tests/qreader_test.py b/tests/qreader_test.py index c44363d..3394fec 100644 --- a/tests/qreader_test.py +++ b/tests/qreader_test.py @@ -16,6 +16,7 @@ import binascii import struct +import os import sys try: from cStringIO import BytesIO @@ -291,7 +292,7 @@ def compare(left, right): def test_reading(): BINARY = OrderedDict() - with open('tests/QExpressions3.out', 'rb') as f: + with open(os.path.join(TEST_DATA_DIR, 'QExpressions3.out'), 'rb') as f: while True: query = f.readline().strip() binary = f.readline().strip() diff --git a/tests/qwriter_test.py b/tests/qwriter_test.py index 1ebaee0..4948f41 100644 --- a/tests/qwriter_test.py +++ b/tests/qwriter_test.py @@ -15,6 +15,7 @@ # import binascii +import os import sys if sys.version > '3': long = int @@ -26,322 +27,422 @@ from qpython.qtemporal import qtemporal, to_raw_qtemporal, array_to_raw_qtemporal BINARY = OrderedDict() +TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'test_data') EXPRESSIONS = OrderedDict(( - (b'("G"$"8c680a01-5a49-5aab-5a65-d4bfddb6a661"; 0Ng)', - qlist(numpy.array([uuid.UUID('8c680a01-5a49-5aab-5a65-d4bfddb6a661'), qnull(QGUID)]), qtype=QGUID_LIST)), - (b'"G"$"8c680a01-5a49-5aab-5a65-d4bfddb6a661"', uuid.UUID('8c680a01-5a49-5aab-5a65-d4bfddb6a661')), - (b'"G"$"00000000-0000-0000-0000-000000000000"', uuid.UUID('00000000-0000-0000-0000-000000000000')), - (b'(2001.01m; 0Nm)', (qlist(numpy.array([to_raw_qtemporal(numpy.datetime64('2001-01', 'M'), QMONTH), qnull(QMONTH)]), qtype=QMONTH_LIST), - qlist(numpy.array([12, qnull(QMONTH)]), qtype=QMONTH_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64('2001-01', 'M'), numpy.datetime64('NaT', 'M')]), qtype = QMONTH_LIST), qtype = QMONTH_LIST), - qlist([12, qnull(QMONTH)], qtype=QMONTH_LIST), - qlist(numpy.array([numpy.datetime64('2001-01'), numpy.datetime64('NaT')], dtype='datetime64[M]'), qtype=QMONTH_LIST), - numpy.array([numpy.datetime64('2001-01'), numpy.datetime64('NaT')], dtype='datetime64[M]'), - )), - (b'2001.01m', (qtemporal(numpy.datetime64('2001-01', 'M'), qtype=QMONTH), - numpy.datetime64('2001-01', 'M'))), - (b'0Nm', (qtemporal(qnull(QMONTH), qtype=QMONTH), - qtemporal(numpy.datetime64('NaT', 'M'), qtype=QMONTH), - numpy.datetime64('NaT', 'M'))), - (b'2001.01.01 2000.05.01 0Nd', (qlist(numpy.array([to_raw_qtemporal(numpy.datetime64('2001-01-01', 'D'), qtype=QDATE), to_raw_qtemporal(numpy.datetime64('2000-05-01', 'D'), qtype=QDATE), qnull(QDATE)]), qtype=QDATE_LIST), - qlist(numpy.array([366, 121, qnull(QDATE)]), qtype=QDATE_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64('2001-01-01', 'D'), numpy.datetime64('2000-05-01', 'D'), numpy.datetime64('NaT', 'D')]), qtype = QDATE_LIST), qtype = QDATE_LIST), - qlist([366, 121, qnull(QDATE)], qtype=QDATE_LIST), - qlist(numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64('2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]'), qtype=QDATE_LIST), - numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64('2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]'), - )), - (b'2001.01.01', (qtemporal(numpy.datetime64('2001-01-01', 'D'), qtype=QDATE), - numpy.datetime64('2001-01-01', 'D'))), - (b'0Nd', (qtemporal(qnull(QDATE), qtype=QDATE), - qtemporal(numpy.datetime64('NaT', 'D'), qtype=QDATE), - numpy.datetime64('NaT', 'D'))), - (b'2000.01.04T05:36:57.600 0Nz', (qlist(numpy.array([3.234, qnull(QDATETIME)]), qtype=QDATETIME_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'), numpy.datetime64('nat', 'ms')]), qtype=QDATETIME_LIST), qtype=QDATETIME_LIST), - qlist([3.234, qnull(QDATETIME)], qtype=QDATETIME_LIST), - qlist(numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'), numpy.datetime64('nat', 'ms')]), qtype = QDATETIME_LIST), - numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'), numpy.datetime64('nat', 'ms')]) - )), - (b'2000.01.04T05:36:57.600', (qtemporal(numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'), qtype=QDATETIME), - numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'))), - (b'0Nz', (qtemporal(qnull(QDATETIME), qtype=QDATETIME), - qtemporal(numpy.datetime64('NaT', 'ms'), qtype=QDATETIME), - numpy.datetime64('NaT', 'ms'))), - (b'12:01 0Nu', (qlist(numpy.array([721, qnull(QMINUTE)]), qtype=QMINUTE_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64(721, 'm'), numpy.timedelta64('nat', 'm')]), qtype=QMINUTE_LIST), qtype=QMINUTE_LIST), - qlist([721, qnull(QMINUTE)], qtype=QMINUTE_LIST), - qlist(numpy.array([numpy.timedelta64(721, 'm'), numpy.timedelta64('nat', 'm')]), qtype = QMINUTE), - numpy.array([numpy.timedelta64(721, 'm'), numpy.timedelta64('nat', 'm')]), - )), - (b'12:01', (qtemporal(numpy.timedelta64(721, 'm'), qtype=QMINUTE), - numpy.timedelta64(721, 'm'))), - (b'0Nu', (qtemporal(qnull(QMINUTE), qtype=QMINUTE), - qtemporal(numpy.timedelta64('NaT', 'm'), qtype=QMINUTE), - numpy.timedelta64('NaT', 'm'))), - (b'12:05:00 0Nv', (qlist(numpy.array([43500, qnull(QSECOND)]), qtype=QSECOND_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64(43500, 's'), numpy.timedelta64('nat', 's')]), qtype=QSECOND_LIST), qtype=QSECOND_LIST), - qlist([43500, qnull(QSECOND)], qtype=QSECOND_LIST), - qlist(numpy.array([numpy.timedelta64(43500, 's'), numpy.timedelta64('nat', 's')]), qtype = QSECOND), - numpy.array([numpy.timedelta64(43500, 's'), numpy.timedelta64('nat', 's')]) - )), - (b'12:05:00', (qtemporal(numpy.timedelta64(43500, 's'), qtype=QSECOND), - numpy.timedelta64(43500, 's'))), - (b'0Nv', (qtemporal(qnull(QSECOND), qtype=QSECOND), - qtemporal(numpy.timedelta64('nat', 's'), qtype=QSECOND), - numpy.timedelta64('nat', 's'))), - (b'12:04:59.123 0Nt', (qlist(numpy.array([43499123, qnull(QTIME)]), qtype=QTIME_LIST), - qlist([43499123, qnull(QTIME)], qtype=QTIME_LIST), - qlist(numpy.array([numpy.timedelta64(43499123, 'ms'), numpy.timedelta64('nat', 'ms')]), qtype = QTIME_LIST), - numpy.array([numpy.timedelta64(43499123, 'ms'), numpy.timedelta64('nat', 'ms')]) - )), - (b'12:04:59.123', (qtemporal(numpy.timedelta64(43499123, 'ms'), qtype=QTIME), - numpy.timedelta64(43499123, 'ms'))), - (b'0Nt', (qtemporal(qnull(QTIME), qtype=QTIME), - qtemporal(numpy.timedelta64('NaT', 'ms'), qtype=QTIME), - numpy.timedelta64('NaT', 'ms'))), - (b'2000.01.04D05:36:57.600 0Np', (qlist(numpy.array([long(279417600000000), qnull(QTIMESTAMP)]), qtype=QTIMESTAMP_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]), qtype=QTIMESTAMP_LIST), qtype=QTIMESTAMP_LIST), - qlist([long(279417600000000), qnull(QTIMESTAMP)], qtype=QTIMESTAMP_LIST), - qlist(numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]), qtype = QTIMESTAMP_LIST), - numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]) - )), - (b'2000.01.04D05:36:57.600', (qtemporal(numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'), qtype=QTIMESTAMP), - numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'))), - (b'0Np', (qtemporal(qnull(QTIMESTAMP), qtype=QTIMESTAMP), - qtemporal(numpy.datetime64('NaT', 'ns'), qtype=QTIMESTAMP), - numpy.datetime64('NaT', 'ns'))), - (b'0D05:36:57.600 0Nn', (qlist(numpy.array([long(20217600000000), qnull(QTIMESPAN)]), qtype=QTIMESPAN_LIST), - qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64('nat', 'ns')]), qtype=QTIMESPAN_LIST), qtype=QTIMESPAN_LIST), - qlist([long(20217600000000), qnull(QTIMESPAN)], qtype=QTIMESPAN_LIST), - qlist(numpy.array([numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64('nat', 'ns')]), qtype = QTIMESPAN_LIST), - numpy.array([numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64('nat', 'ns')]) - )), - (b'0D05:36:57.600', (qtemporal(numpy.timedelta64(20217600000000, 'ns'), qtype=QTIMESPAN), - numpy.timedelta64(20217600000000, 'ns'))), - (b'0Nn', (qtemporal(qnull(QTIMESPAN), qtype=QTIMESPAN), - qtemporal(numpy.timedelta64('NaT', 'ns'), qtype=QTIMESPAN), - numpy.timedelta64('NaT', 'ns'))), + (b'("G"$"8c680a01-5a49-5aab-5a65-d4bfddb6a661"; 0Ng)', + qlist(numpy.array([uuid.UUID('8c680a01-5a49-5aab-5a65-d4bfddb6a661'), qnull(QGUID)]), qtype=QGUID_LIST)), + (b'"G"$"8c680a01-5a49-5aab-5a65-d4bfddb6a661"', + uuid.UUID('8c680a01-5a49-5aab-5a65-d4bfddb6a661')), + (b'"G"$"00000000-0000-0000-0000-000000000000"', + uuid.UUID('00000000-0000-0000-0000-000000000000')), + (b'(2001.01m; 0Nm)', (qlist(numpy.array([to_raw_qtemporal(numpy.datetime64('2001-01', 'M'), QMONTH), qnull(QMONTH)]), qtype=QMONTH_LIST), + qlist(numpy.array( + [12, qnull(QMONTH)]), qtype=QMONTH_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64( + '2001-01', 'M'), numpy.datetime64('NaT', 'M')]), qtype=QMONTH_LIST), qtype=QMONTH_LIST), + qlist( + [12, qnull(QMONTH)], qtype=QMONTH_LIST), + qlist(numpy.array([numpy.datetime64( + '2001-01'), numpy.datetime64('NaT')], dtype='datetime64[M]'), qtype=QMONTH_LIST), + numpy.array( + [numpy.datetime64('2001-01'), numpy.datetime64('NaT')], dtype='datetime64[M]'), + )), + (b'2001.01m', (qtemporal(numpy.datetime64('2001-01', 'M'), qtype=QMONTH), + numpy.datetime64('2001-01', 'M'))), + (b'0Nm', (qtemporal(qnull(QMONTH), qtype=QMONTH), + qtemporal(numpy.datetime64( + 'NaT', 'M'), qtype=QMONTH), + numpy.datetime64('NaT', 'M'))), + (b'2001.01.01 2000.05.01 0Nd', (qlist(numpy.array([to_raw_qtemporal(numpy.datetime64('2001-01-01', 'D'), qtype=QDATE), to_raw_qtemporal(numpy.datetime64('2000-05-01', 'D'), qtype=QDATE), qnull(QDATE)]), qtype=QDATE_LIST), + qlist(numpy.array( + [366, 121, qnull(QDATE)]), qtype=QDATE_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64('2001-01-01', 'D'), numpy.datetime64( + '2000-05-01', 'D'), numpy.datetime64('NaT', 'D')]), qtype=QDATE_LIST), qtype=QDATE_LIST), + qlist( + [366, 121, qnull(QDATE)], qtype=QDATE_LIST), + qlist(numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64( + '2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]'), qtype=QDATE_LIST), + numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64( + '2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]'), + )), + (b'2001.01.01', (qtemporal(numpy.datetime64('2001-01-01', 'D'), qtype=QDATE), + numpy.datetime64('2001-01-01', 'D'))), + (b'0Nd', (qtemporal(qnull(QDATE), qtype=QDATE), + qtemporal(numpy.datetime64( + 'NaT', 'D'), qtype=QDATE), + numpy.datetime64('NaT', 'D'))), + (b'2000.01.04T05:36:57.600 0Nz', (qlist(numpy.array([3.234, qnull(QDATETIME)]), qtype=QDATETIME_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64( + '2000-01-04T05:36:57.600Z', 'ms'), numpy.datetime64('nat', 'ms')]), qtype=QDATETIME_LIST), qtype=QDATETIME_LIST), + qlist( + [3.234, qnull(QDATETIME)], qtype=QDATETIME_LIST), + qlist(numpy.array([numpy.datetime64('2000-01-04T05:36:57.600Z', + 'ms'), numpy.datetime64('nat', 'ms')]), qtype=QDATETIME_LIST), + numpy.array([numpy.datetime64( + '2000-01-04T05:36:57.600Z', 'ms'), numpy.datetime64('nat', 'ms')]) + )), + (b'2000.01.04T05:36:57.600', (qtemporal(numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'), qtype=QDATETIME), + numpy.datetime64('2000-01-04T05:36:57.600Z', 'ms'))), + (b'0Nz', (qtemporal(qnull(QDATETIME), qtype=QDATETIME), + qtemporal(numpy.datetime64( + 'NaT', 'ms'), qtype=QDATETIME), + numpy.datetime64('NaT', 'ms'))), + (b'12:01 0Nu', (qlist(numpy.array([721, qnull(QMINUTE)]), qtype=QMINUTE_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64( + 721, 'm'), numpy.timedelta64('nat', 'm')]), qtype=QMINUTE_LIST), qtype=QMINUTE_LIST), + qlist( + [721, qnull(QMINUTE)], qtype=QMINUTE_LIST), + qlist(numpy.array([numpy.timedelta64(721, 'm'), + numpy.timedelta64('nat', 'm')]), qtype=QMINUTE), + numpy.array( + [numpy.timedelta64(721, 'm'), numpy.timedelta64('nat', 'm')]), + )), + (b'12:01', (qtemporal(numpy.timedelta64(721, 'm'), qtype=QMINUTE), + numpy.timedelta64(721, 'm'))), + (b'0Nu', (qtemporal(qnull(QMINUTE), qtype=QMINUTE), + qtemporal(numpy.timedelta64( + 'NaT', 'm'), qtype=QMINUTE), + numpy.timedelta64('NaT', 'm'))), + (b'12:05:00 0Nv', (qlist(numpy.array([43500, qnull(QSECOND)]), qtype=QSECOND_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64( + 43500, 's'), numpy.timedelta64('nat', 's')]), qtype=QSECOND_LIST), qtype=QSECOND_LIST), + qlist( + [43500, qnull(QSECOND)], qtype=QSECOND_LIST), + qlist(numpy.array([numpy.timedelta64(43500, 's'), + numpy.timedelta64('nat', 's')]), qtype=QSECOND), + numpy.array( + [numpy.timedelta64(43500, 's'), numpy.timedelta64('nat', 's')]) + )), + (b'12:05:00', (qtemporal(numpy.timedelta64(43500, 's'), qtype=QSECOND), + numpy.timedelta64(43500, 's'))), + (b'0Nv', (qtemporal(qnull(QSECOND), qtype=QSECOND), + qtemporal(numpy.timedelta64( + 'nat', 's'), qtype=QSECOND), + numpy.timedelta64('nat', 's'))), + (b'12:04:59.123 0Nt', (qlist(numpy.array([43499123, qnull(QTIME)]), qtype=QTIME_LIST), + qlist( + [43499123, qnull(QTIME)], qtype=QTIME_LIST), + qlist(numpy.array([numpy.timedelta64(43499123, 'ms'), + numpy.timedelta64('nat', 'ms')]), qtype=QTIME_LIST), + numpy.array( + [numpy.timedelta64(43499123, 'ms'), numpy.timedelta64('nat', 'ms')]) + )), + (b'12:04:59.123', (qtemporal(numpy.timedelta64(43499123, 'ms'), qtype=QTIME), + numpy.timedelta64(43499123, 'ms'))), + (b'0Nt', (qtemporal(qnull(QTIME), qtype=QTIME), + qtemporal(numpy.timedelta64( + 'NaT', 'ms'), qtype=QTIME), + numpy.timedelta64('NaT', 'ms'))), + (b'2000.01.04D05:36:57.600 0Np', (qlist(numpy.array([long(279417600000000), qnull(QTIMESTAMP)]), qtype=QTIMESTAMP_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.datetime64( + '2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]), qtype=QTIMESTAMP_LIST), qtype=QTIMESTAMP_LIST), + qlist([long(279417600000000), qnull( + QTIMESTAMP)], qtype=QTIMESTAMP_LIST), + qlist(numpy.array([numpy.datetime64( + '2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]), qtype=QTIMESTAMP_LIST), + numpy.array([numpy.datetime64( + '2000-01-04T05:36:57.600Z', 'ns'), numpy.datetime64('nat', 'ns')]) + )), + (b'2000.01.04D05:36:57.600', (qtemporal(numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'), qtype=QTIMESTAMP), + numpy.datetime64('2000-01-04T05:36:57.600Z', 'ns'))), + (b'0Np', (qtemporal(qnull(QTIMESTAMP), qtype=QTIMESTAMP), + qtemporal(numpy.datetime64( + 'NaT', 'ns'), qtype=QTIMESTAMP), + numpy.datetime64('NaT', 'ns'))), + (b'0D05:36:57.600 0Nn', (qlist(numpy.array([long(20217600000000), qnull(QTIMESPAN)]), qtype=QTIMESPAN_LIST), + qlist(array_to_raw_qtemporal(numpy.array([numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64( + 'nat', 'ns')]), qtype=QTIMESPAN_LIST), qtype=QTIMESPAN_LIST), + qlist([long(20217600000000), qnull( + QTIMESPAN)], qtype=QTIMESPAN_LIST), + qlist(numpy.array([numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64( + 'nat', 'ns')]), qtype=QTIMESPAN_LIST), + numpy.array( + [numpy.timedelta64(20217600000000, 'ns'), numpy.timedelta64('nat', 'ns')]) + )), + (b'0D05:36:57.600', (qtemporal(numpy.timedelta64(20217600000000, 'ns'), qtype=QTIMESPAN), + numpy.timedelta64(20217600000000, 'ns'))), + (b'0Nn', (qtemporal(qnull(QTIMESPAN), qtype=QTIMESPAN), + qtemporal(numpy.timedelta64( + 'NaT', 'ns'), qtype=QTIMESPAN), + numpy.timedelta64('NaT', 'ns'))), - (b'::', None), - (b'1+`', QException('type')), - (b'1', numpy.int64(1)), - (b'1i', numpy.int32(1)), - (b'-234h', numpy.int16(-234)), - (b'0b', numpy.bool_(False)), - (b'1b', numpy.bool_(True)), - (b'0x2a', numpy.byte(0x2a)), - (b'89421099511627575j', numpy.int64(long(89421099511627575))), - (b'5.5e', numpy.float32(5.5)), - (b'3.234', numpy.float64(3.234)), - (b'"0"', '0'), - (b'"abc"', ('abc', - numpy.array(list('abc'), dtype='S'))), - (b'"quick brown fox jumps over a lazy dog"', 'quick brown fox jumps over a lazy dog'), - (b'`abc', numpy.string_('abc')), - (b'`quickbrownfoxjumpsoveralazydog', numpy.string_('quickbrownfoxjumpsoveralazydog')), - (b'0Nh', qnull(QSHORT)), - (b'0N', qnull(QLONG)), - (b'0Ni', qnull(QINT)), - (b'0Nj', qnull(QLONG)), - (b'0Ne', qnull(QFLOAT)), - (b'0n', qnull(QDOUBLE)), - (b'" "', qnull(QSTRING)), - (b'`', qnull(QSYMBOL)), - (b'0Ng', qnull(QGUID)), - (b'()', []), - (b'(0b;1b;0b)', (numpy.array([False, True, False], dtype=numpy.bool_), - qlist(numpy.array([False, True, False]), qtype = QBOOL_LIST), - qlist([False, True, False], qtype = QBOOL_LIST))), - (b'(0x01;0x02;0xff)', (numpy.array([0x01, 0x02, 0xff], dtype=numpy.byte), - qlist(numpy.array([0x01, 0x02, 0xff], dtype=numpy.byte), qtype = QBYTE_LIST), - qlist(numpy.array([0x01, 0x02, 0xff]), qtype = QBYTE_LIST), - qlist([0x01, 0x02, 0xff], qtype = QBYTE_LIST))), - (b'(1h;2h;3h)', (numpy.array([1, 2, 3], dtype=numpy.int16), - qlist(numpy.array([1, 2, 3], dtype=numpy.int16), qtype = QSHORT_LIST), - qlist(numpy.array([1, 2, 3]), qtype = QSHORT_LIST), - qlist([1, 2, 3], qtype = QSHORT_LIST))), - (b'(1h;0Nh;3h)', qlist(numpy.array([1, qnull(QSHORT), 3], dtype=numpy.int16), qtype=QSHORT_LIST)), - (b'1 2 3', (numpy.array([1, 2, 3], dtype=numpy.int64), - qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype = QLONG_LIST), - qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - qlist([1, 2, 3], qtype = QLONG_LIST))), - (b'1 0N 3', qlist(numpy.array([1, qnull(QLONG), 3], dtype=numpy.int64), qtype=QLONG_LIST)), - (b'(1i;2i;3i)', (numpy.array([1, 2, 3], dtype=numpy.int32), - qlist(numpy.array([1, 2, 3], dtype=numpy.int32), qtype = QINT_LIST), - qlist(numpy.array([1, 2, 3]), qtype = QINT_LIST), - qlist([1, 2, 3], qtype = QINT_LIST))), - (b'(1i;0Ni;3i)', qlist(numpy.array([1, qnull(QINT), 3], dtype=numpy.int32), qtype=QINT_LIST)), - (b'(1j;2j;3j)', (numpy.array([1, 2, 3], dtype=numpy.int64), - qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype = QLONG_LIST), - qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - qlist([1, 2, 3], qtype = QLONG_LIST))), - (b'(1j;0Nj;3j)', qlist(numpy.array([1, qnull(QLONG), 3], dtype=numpy.int64), qtype=QLONG_LIST)), - (b'(5.5e; 8.5e)', (numpy.array([5.5, 8.5], dtype=numpy.float32), - qlist(numpy.array([5.5, 8.5], dtype=numpy.float32), qtype = QFLOAT_LIST), - qlist(numpy.array([5.5, 8.5]), qtype = QFLOAT_LIST), - qlist([5.5, 8.5], qtype = QFLOAT_LIST))), - (b'(5.5e; 0Ne)', qlist(numpy.array([5.5, qnull(QFLOAT)], dtype=numpy.float32), qtype=QFLOAT_LIST)), - (b'3.23 6.46', (numpy.array([3.23, 6.46], dtype=numpy.float64), - qlist(numpy.array([3.23, 6.46], dtype=numpy.float64), qtype = QDOUBLE_LIST), - qlist(numpy.array([3.23, 6.46]), qtype = QDOUBLE_LIST), - qlist([3.23, 6.46], qtype = QDOUBLE_LIST))), - (b'3.23 0n', qlist(numpy.array([3.23, qnull(QDOUBLE)], dtype=numpy.float64), qtype=QDOUBLE_LIST)), - (b'(1;`bcd;"0bc";5.5e)', [numpy.int64(1), numpy.string_('bcd'), '0bc', numpy.float32(5.5)]), - (b'(42;::;`foo)', [numpy.int64(42), None, numpy.string_('foo')]), - (b'(1;2h;3.234;"4")', [numpy.int64(1), numpy.int16(2), numpy.float64(3.234), '4']), - (b'(`one;2 3;"456";(7;8 9))', [numpy.string_('one'), qlist(numpy.array([2, 3], dtype=numpy.int64), qtype=QLONG_LIST), '456', [numpy.int64(7), qlist(numpy.array([8, 9], dtype=numpy.int64), qtype=QLONG_LIST)]]), + (b'::', None), + (b'1+`', + QException('type')), + (b'1', + numpy.int64(1)), + (b'1i', + numpy.int32(1)), + (b'-234h', + numpy.int16(-234)), + (b'0b', + numpy.bool_(False)), + (b'1b', + numpy.bool_(True)), + (b'0x2a', + numpy.byte(0x2a)), + (b'89421099511627575j', + numpy.int64(long(89421099511627575))), + (b'5.5e', + numpy.float32(5.5)), + (b'3.234', + numpy.float64(3.234)), + (b'"0"', '0'), + (b'"abc"', ('abc', + numpy.array(list('abc'), dtype='S'))), + (b'"quick brown fox jumps over a lazy dog"', + 'quick brown fox jumps over a lazy dog'), + (b'`abc', + numpy.string_('abc')), + (b'`quickbrownfoxjumpsoveralazydog', + numpy.string_('quickbrownfoxjumpsoveralazydog')), + (b'0Nh', qnull(QSHORT)), + (b'0N', qnull(QLONG)), + (b'0Ni', qnull(QINT)), + (b'0Nj', qnull(QLONG)), + (b'0Ne', qnull(QFLOAT)), + (b'0n', + qnull(QDOUBLE)), + (b'" "', + qnull(QSTRING)), + (b'`', + qnull(QSYMBOL)), + (b'0Ng', qnull(QGUID)), + (b'()', []), + (b'(0b;1b;0b)', (numpy.array([False, True, False], dtype=numpy.bool_), + qlist(numpy.array( + [False, True, False]), qtype=QBOOL_LIST), + qlist([False, True, False], qtype=QBOOL_LIST))), + (b'(0x01;0x02;0xff)', (numpy.array([0x01, 0x02, 0xff], dtype=numpy.byte), + qlist(numpy.array( + [0x01, 0x02, 0xff], dtype=numpy.byte), qtype=QBYTE_LIST), + qlist(numpy.array( + [0x01, 0x02, 0xff]), qtype=QBYTE_LIST), + qlist([0x01, 0x02, 0xff], qtype=QBYTE_LIST))), + (b'(1h;2h;3h)', (numpy.array([1, 2, 3], dtype=numpy.int16), + qlist(numpy.array( + [1, 2, 3], dtype=numpy.int16), qtype=QSHORT_LIST), + qlist(numpy.array( + [1, 2, 3]), qtype=QSHORT_LIST), + qlist([1, 2, 3], qtype=QSHORT_LIST))), + (b'(1h;0Nh;3h)', qlist( + numpy.array([1, qnull(QSHORT), 3], dtype=numpy.int16), qtype=QSHORT_LIST)), + (b'1 2 3', (numpy.array([1, 2, 3], dtype=numpy.int64), + qlist(numpy.array( + [1, 2, 3], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array( + [1, 2, 3]), qtype=QLONG_LIST), + qlist([1, 2, 3], qtype=QLONG_LIST))), + (b'1 0N 3', qlist( + numpy.array([1, qnull(QLONG), 3], dtype=numpy.int64), qtype=QLONG_LIST)), + (b'(1i;2i;3i)', (numpy.array([1, 2, 3], dtype=numpy.int32), + qlist(numpy.array( + [1, 2, 3], dtype=numpy.int32), qtype=QINT_LIST), + qlist(numpy.array( + [1, 2, 3]), qtype=QINT_LIST), + qlist([1, 2, 3], qtype=QINT_LIST))), + (b'(1i;0Ni;3i)', qlist( + numpy.array([1, qnull(QINT), 3], dtype=numpy.int32), qtype=QINT_LIST)), + (b'(1j;2j;3j)', (numpy.array([1, 2, 3], dtype=numpy.int64), + qlist(numpy.array( + [1, 2, 3], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array( + [1, 2, 3]), qtype=QLONG_LIST), + qlist([1, 2, 3], qtype=QLONG_LIST))), + (b'(1j;0Nj;3j)', qlist( + numpy.array([1, qnull(QLONG), 3], dtype=numpy.int64), qtype=QLONG_LIST)), + (b'(5.5e; 8.5e)', (numpy.array([5.5, 8.5], dtype=numpy.float32), + qlist(numpy.array( + [5.5, 8.5], dtype=numpy.float32), qtype=QFLOAT_LIST), + qlist(numpy.array( + [5.5, 8.5]), qtype=QFLOAT_LIST), + qlist([5.5, 8.5], qtype=QFLOAT_LIST))), + (b'(5.5e; 0Ne)', qlist(numpy.array( + [5.5, qnull(QFLOAT)], dtype=numpy.float32), qtype=QFLOAT_LIST)), + (b'3.23 6.46', (numpy.array([3.23, 6.46], dtype=numpy.float64), + qlist(numpy.array( + [3.23, 6.46], dtype=numpy.float64), qtype=QDOUBLE_LIST), + qlist(numpy.array( + [3.23, 6.46]), qtype=QDOUBLE_LIST), + qlist([3.23, 6.46], qtype=QDOUBLE_LIST))), + (b'3.23 0n', qlist(numpy.array( + [3.23, qnull(QDOUBLE)], dtype=numpy.float64), qtype=QDOUBLE_LIST)), + (b'(1;`bcd;"0bc";5.5e)', [ + numpy.int64(1), numpy.string_('bcd'), '0bc', numpy.float32(5.5)]), + (b'(42;::;`foo)', [ + numpy.int64(42), None, numpy.string_('foo')]), + (b'(1;2h;3.234;"4")', [ + numpy.int64(1), numpy.int16(2), numpy.float64(3.234), '4']), + (b'(`one;2 3;"456";(7;8 9))', [numpy.string_('one'), qlist(numpy.array( + [2, 3], dtype=numpy.int64), qtype=QLONG_LIST), '456', [numpy.int64(7), qlist(numpy.array([8, 9], dtype=numpy.int64), qtype=QLONG_LIST)]]), - (b'`jumps`over`a`lazy`dog', (numpy.array(['jumps', 'over', 'a', 'lazy', 'dog'], dtype=numpy.string_), - qlist(numpy.array(['jumps', 'over', 'a', 'lazy', 'dog']), qtype = QSYMBOL_LIST), - qlist(['jumps', 'over', 'a', 'lazy', 'dog'], qtype = QSYMBOL_LIST))), - (b'`the`quick`brown`fox', numpy.array([numpy.string_('the'), numpy.string_('quick'), numpy.string_('brown'), numpy.string_('fox')], dtype=numpy.object)), - (b'``quick``fox', qlist(numpy.array([qnull(QSYMBOL), numpy.string_('quick'), qnull(QSYMBOL), numpy.string_('fox')], dtype=numpy.object), qtype=QSYMBOL_LIST)), - (b'``', qlist(numpy.array([qnull(QSYMBOL), qnull(QSYMBOL)], dtype=numpy.object), qtype=QSYMBOL_LIST)), - (b'("quick"; "brown"; "fox"; "jumps"; "over"; "a lazy"; "dog")', - (['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog'], - qlist(numpy.array(['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog']), qtype = QSTRING_LIST), - qlist(['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog'], qtype = QSTRING_LIST))), - (b'{x+y}', QLambda('{x+y}')), - (b'{x+y}[3]', QProjection([QLambda('{x+y}'), numpy.int64(3)])), + (b'`jumps`over`a`lazy`dog', (numpy.array(['jumps', 'over', 'a', 'lazy', 'dog'], dtype=numpy.string_), + qlist(numpy.array( + ['jumps', 'over', 'a', 'lazy', 'dog']), qtype=QSYMBOL_LIST), + qlist(['jumps', 'over', 'a', 'lazy', 'dog'], qtype=QSYMBOL_LIST))), + (b'`the`quick`brown`fox', numpy.array([numpy.string_('the'), numpy.string_( + 'quick'), numpy.string_('brown'), numpy.string_('fox')], dtype=numpy.object)), + (b'``quick``fox', qlist(numpy.array([qnull(QSYMBOL), numpy.string_( + 'quick'), qnull(QSYMBOL), numpy.string_('fox')], dtype=numpy.object), qtype=QSYMBOL_LIST)), + (b'``', qlist(numpy.array( + [qnull(QSYMBOL), qnull(QSYMBOL)], dtype=numpy.object), qtype=QSYMBOL_LIST)), + (b'("quick"; "brown"; "fox"; "jumps"; "over"; "a lazy"; "dog")', + (['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog'], + qlist(numpy.array( + ['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog']), qtype=QSTRING_LIST), + qlist(['quick', 'brown', 'fox', 'jumps', 'over', 'a lazy', 'dog'], qtype=QSTRING_LIST))), + (b'{x+y}', + QLambda('{x+y}')), + (b'{x+y}[3]', + QProjection([QLambda('{x+y}'), numpy.int64(3)])), - (b'(enlist `a)!(enlist 1)', (QDictionary(qlist(numpy.array(['a']), qtype = QSYMBOL_LIST), - qlist(numpy.array([1], dtype=numpy.int64), qtype=QLONG_LIST)), - QDictionary(qlist(numpy.array(['a']), qtype = QSYMBOL_LIST), - qlist(numpy.array([1]), qtype=QLONG_LIST)))), - (b'1 2!`abc`cdefgh', QDictionary(qlist(numpy.array([1, 2], dtype=numpy.int64), qtype=QLONG_LIST), - qlist(numpy.array(['abc', 'cdefgh']), qtype = QSYMBOL_LIST))), - (b'`abc`def`gh!([] one: 1 2 3; two: 4 5 6)', QDictionary(qlist(numpy.array(['abc', 'def', 'gh']), qtype = QSYMBOL_LIST), - qtable(qlist(numpy.array(['one', 'two']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - qlist(numpy.array([4, 5, 6]), qtype = QLONG_LIST)]))), - (b'(`x`y!(`a;2))', QDictionary(qlist(numpy.array(['x', 'y']), qtype = QSYMBOL_LIST), - [numpy.string_('a'), numpy.int64(2)])), - (b'(0 1; 2 3)!`first`second', QDictionary([qlist(numpy.array([0, 1], dtype=numpy.int64), qtype=QLONG_LIST), qlist(numpy.array([2, 3], dtype=numpy.int64), qtype=QLONG_LIST)], - qlist(numpy.array(['first', 'second']), qtype = QSYMBOL_LIST))), - (b'(1;2h;3.234;"4")!(`one;2 3;"456";(7;8 9))', QDictionary([numpy.int64(1), numpy.int16(2), numpy.float64(3.234), '4'], - [numpy.string_('one'), qlist(numpy.array([2, 3], dtype=numpy.int64), qtype=QLONG_LIST), '456', [numpy.int64(7), qlist(numpy.array([8, 9], dtype=numpy.int64), qtype=QLONG_LIST)]])), - (b'`A`B`C!((1;3.234;3);(`x`y!(`a;2));5.5e)', QDictionary(qlist(numpy.array(['A', 'B', 'C']), qtype = QSYMBOL_LIST), - [[numpy.int64(1), numpy.float64(3.234), numpy.int64(3)], QDictionary(qlist(numpy.array(['x', 'y']), qtype = QSYMBOL_LIST), [numpy.string_('a'), numpy.int64(2)]), numpy.float32(5.5)])), - - (b'flip `abc`def!(1 2 3; 4 5 6)', (qtable(qlist(numpy.array(['abc', 'def']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype=QLONG_LIST), - qlist(numpy.array([4, 5, 6], dtype=numpy.int64), qtype=QLONG_LIST)], - qtype=QTABLE), - qtable(qlist(numpy.array(['abc', 'def']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - qlist(numpy.array([4, 5, 6]), qtype = QLONG_LIST)]), - qtable(qlist(['abc', 'def'], qtype = QSYMBOL_LIST), - [qlist([1, 2, 3], qtype = QLONG_LIST), - qlist([4, 5, 6], qtype = QLONG_LIST)]), - qtable(qlist(['abc', 'def'], qtype = QSYMBOL_LIST), - [qlist([1, 2, 3]), qlist([4, 5, 6])], - **{'abc': QLONG_LIST, 'def': QLONG_LIST}), - qtable(['abc', 'def'], - [[1, 2, 3], [4, 5, 6]], - **{'abc': QLONG, 'def': QLONG}))), - (b'flip `name`iq!(`Dent`Beeblebrox`Prefect;98 42 126)', - (qtable(qlist(numpy.array(['name', 'iq']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype = QSYMBOL_LIST), - qlist(numpy.array([98, 42, 126], dtype=numpy.int64), qtype = QLONG_LIST)]), - qtable(qlist(numpy.array(['name', 'iq']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype = QSYMBOL_LIST), - qlist(numpy.array([98, 42, 126]), qtype = QLONG_LIST)]), - qtable(qlist(['name', 'iq'], qtype = QSYMBOL_LIST), - [qlist(['Dent', 'Beeblebrox', 'Prefect'], qtype = QSYMBOL_LIST), - qlist([98, 42, 126], qtype = QLONG_LIST)]), - qtable(qlist(['name', 'iq'], qtype = QSYMBOL_LIST), - [qlist(['Dent', 'Beeblebrox', 'Prefect']), - qlist([98, 42, 126])], - name = QSYMBOL, iq = QLONG), - qtable(['name', 'iq'], - [['Dent', 'Beeblebrox', 'Prefect'], - [98, 42, 126]], - name = QSYMBOL, iq = QLONG), - qtable(['name', 'iq'], - [['Dent', 'Beeblebrox', 'Prefect'], - [98, 42, 126]], - **{'name': QSYMBOL, 'iq': QLONG}))), - (b'flip `name`iq`grade!(`Dent`Beeblebrox`Prefect;98 42 126;"a c")', - qtable(qlist(numpy.array(['name', 'iq', 'grade']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype = QSYMBOL_LIST), - qlist(numpy.array([98, 42, 126]), qtype = QLONG_LIST), - "a c"])), - (b'flip `name`iq`fullname!(`Dent`Beeblebrox`Prefect;98 42 126;("Arthur Dent"; "Zaphod Beeblebrox"; "Ford Prefect"))', - qtable(qlist(numpy.array(['name', 'iq', 'fullname']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype = QSYMBOL_LIST), - qlist(numpy.array([98, 42, 126]), qtype = QLONG_LIST), - qlist(numpy.array(["Arthur Dent", "Zaphod Beeblebrox", "Ford Prefect"]), qtype = QSTRING_LIST)])), - (b'flip `name`iq`misc!(`Dent`Beeblebrox`Prefect;98 42 126;("The Hitch Hiker\'s Guide to the Galaxy"; 160; 1979.10.12))', - qtable(qlist(numpy.array(['name', 'iq', 'misc']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype = QSYMBOL_LIST), - qlist(numpy.array([98, 42, 126]), qtype = QLONG_LIST), - qlist(numpy.array(["The Hitch Hiker\'s Guide to the Galaxy", long(160), qtemporal(numpy.datetime64('1979-10-12', 'D'), qtype=QDATE)]), qtype = QGENERAL_LIST)])), - (b'([] sc:1 2 3; nsc:(1 2; 3 4; 5 6 7))', (qtable(qlist(numpy.array(['sc', 'nsc']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype = QLONG_LIST), - [qlist(numpy.array([1, 2], dtype=numpy.int64), qtype = QLONG_LIST), - qlist(numpy.array([3, 4], dtype=numpy.int64), qtype = QLONG_LIST), - qlist(numpy.array([5, 6, 7], dtype=numpy.int64), qtype = QLONG_LIST)]]), - qtable(qlist(numpy.array(['sc', 'nsc']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - [qlist(numpy.array([1, 2]), qtype = QLONG_LIST), - qlist(numpy.array([3, 4]), qtype = QLONG_LIST), - qlist(numpy.array([5, 6, 7]), qtype = QLONG_LIST)]]), - qtable(qlist(['sc', 'nsc'], qtype = QSYMBOL_LIST), - [qlist([1, 2, 3], qtype = QLONG_LIST), - [qlist([1, 2], qtype = QLONG_LIST), - qlist([3, 4], qtype = QLONG_LIST), - qlist([5, 6, 7], qtype = QLONG_LIST)]]))), - (b'([] sc:1 2 3; nsc:(1 2; 3 4; 5 6))', qtable(qlist(numpy.array(['sc', 'nsc']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1, 2, 3]), qtype = QLONG_LIST), - [qlist(numpy.array([1, 2]), qtype = QLONG_LIST), - qlist(numpy.array([3, 4]), qtype = QLONG_LIST), - qlist(numpy.array([5, 6]), qtype = QLONG_LIST)]])), - (b'1#([] sym:`x`x`x;str:" a")', {'data': qtable(qlist(numpy.array(['sym', 'str']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['x'], dtype=numpy.string_), qtype = QSYMBOL_LIST), - b" "]), - 'single_char_strings': True - }), - (b'-1#([] sym:`x`x`x;str:" a")', {'data': qtable(qlist(numpy.array(['sym', 'str']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['x'], dtype=numpy.string_), qtype = QSYMBOL_LIST), - b"a"]), - 'single_char_strings': True - }), - (b'2#([] sym:`x`x`x`x;str:" aa")', qtable(qlist(numpy.array(['sym', 'str']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['x', 'x'], dtype=numpy.string_), qtype = QSYMBOL_LIST), - b" "])), - (b'-2#([] sym:`x`x`x`x;str:" aa")', qtable(qlist(numpy.array(['sym', 'str']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['x', 'x'], dtype=numpy.string_), qtype = QSYMBOL_LIST), - b"aa"])), - (b'([] name:`symbol$(); iq:`int$())', (qtable(qlist(numpy.array(['name', 'iq']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([], dtype=numpy.string_), qtype = QSYMBOL_LIST), - qlist(numpy.array([], dtype=numpy.int32), qtype = QINT_LIST)]), - qtable(qlist(numpy.array(['name', 'iq']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([]), qtype = QSYMBOL_LIST), - qlist(numpy.array([]), qtype = QINT_LIST)]), - qtable(qlist(['name', 'iq'], qtype = QSYMBOL_LIST), - [qlist([], qtype = QSYMBOL_LIST), - qlist([], qtype = QINT_LIST)]))), - (b'([] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))', - (qtable(qlist(numpy.array(['pos', 'dates']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['d1', 'd2', 'd3']), qtype = QSYMBOL_LIST), - qlist(numpy.array([366, 121, qnull(QDATE)]), qtype=QDATE_LIST)]), - qtable(['pos', 'dates'], - [qlist(numpy.array(['d1', 'd2', 'd3']), qtype = QSYMBOL_LIST), - numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64('2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]')]) - )), - (b'([eid:1001 1002 1003] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))', - QKeyedTable(qtable(qlist(numpy.array(['eid']), qtype = QSYMBOL_LIST), - [qlist(numpy.array([1001, 1002, 1003]), qtype = QLONG_LIST)]), - qtable(qlist(numpy.array(['pos', 'dates']), qtype = QSYMBOL_LIST), - [qlist(numpy.array(['d1', 'd2', 'd3']), qtype = QSYMBOL_LIST), - qlist(numpy.array([366, 121, qnull(QDATE)]), qtype = QDATE_LIST)])) - ), - )) + (b'(enlist `a)!(enlist 1)', (QDictionary(qlist(numpy.array(['a']), qtype=QSYMBOL_LIST), + qlist(numpy.array([1], dtype=numpy.int64), qtype=QLONG_LIST)), + QDictionary(qlist(numpy.array(['a']), qtype=QSYMBOL_LIST), + qlist(numpy.array([1]), qtype=QLONG_LIST)))), + (b'1 2!`abc`cdefgh', QDictionary(qlist(numpy.array([1, 2], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array(['abc', 'cdefgh']), qtype=QSYMBOL_LIST))), + (b'`abc`def`gh!([] one: 1 2 3; two: 4 5 6)', QDictionary(qlist(numpy.array(['abc', 'def', 'gh']), qtype=QSYMBOL_LIST), + qtable(qlist(numpy.array(['one', 'two']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3]), qtype=QLONG_LIST), + qlist(numpy.array([4, 5, 6]), qtype=QLONG_LIST)]))), + (b'(`x`y!(`a;2))', QDictionary(qlist(numpy.array(['x', 'y']), qtype=QSYMBOL_LIST), + [numpy.string_('a'), numpy.int64(2)])), + (b'(0 1; 2 3)!`first`second', QDictionary([qlist(numpy.array([0, 1], dtype=numpy.int64), qtype=QLONG_LIST), qlist(numpy.array([2, 3], dtype=numpy.int64), qtype=QLONG_LIST)], + qlist(numpy.array(['first', 'second']), qtype=QSYMBOL_LIST))), + (b'(1;2h;3.234;"4")!(`one;2 3;"456";(7;8 9))', QDictionary([numpy.int64(1), numpy.int16(2), numpy.float64(3.234), '4'], + [numpy.string_('one'), qlist(numpy.array([2, 3], dtype=numpy.int64), qtype=QLONG_LIST), '456', [numpy.int64(7), qlist(numpy.array([8, 9], dtype=numpy.int64), qtype=QLONG_LIST)]])), + (b'`A`B`C!((1;3.234;3);(`x`y!(`a;2));5.5e)', QDictionary(qlist(numpy.array(['A', 'B', 'C']), qtype=QSYMBOL_LIST), + [[numpy.int64(1), numpy.float64(3.234), numpy.int64(3)], QDictionary(qlist(numpy.array(['x', 'y']), qtype=QSYMBOL_LIST), [numpy.string_('a'), numpy.int64(2)]), numpy.float32(5.5)])), + (b'flip `abc`def!(1 2 3; 4 5 6)', (qtable(qlist(numpy.array(['abc', 'def']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array([4, 5, 6], dtype=numpy.int64), qtype=QLONG_LIST)], + qtype=QTABLE), + qtable(qlist(numpy.array(['abc', 'def']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3]), qtype=QLONG_LIST), + qlist(numpy.array([4, 5, 6]), qtype=QLONG_LIST)]), + qtable(qlist(['abc', 'def'], qtype=QSYMBOL_LIST), + [qlist([1, 2, 3], qtype=QLONG_LIST), + qlist([4, 5, 6], qtype=QLONG_LIST)]), + qtable(qlist(['abc', 'def'], qtype=QSYMBOL_LIST), + [qlist([1, 2, 3]), qlist( + [4, 5, 6])], + **{'abc': QLONG_LIST, 'def': QLONG_LIST}), + qtable(['abc', 'def'], + [[1, 2, 3], [ + 4, 5, 6]], + **{'abc': QLONG, 'def': QLONG}))), + (b'flip `name`iq!(`Dent`Beeblebrox`Prefect;98 42 126)', + (qtable(qlist(numpy.array(['name', 'iq']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype=QSYMBOL_LIST), + qlist(numpy.array([98, 42, 126], dtype=numpy.int64), qtype=QLONG_LIST)]), + qtable(qlist(numpy.array(['name', 'iq']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype=QSYMBOL_LIST), + qlist(numpy.array([98, 42, 126]), qtype=QLONG_LIST)]), + qtable(qlist(['name', 'iq'], qtype=QSYMBOL_LIST), + [qlist(['Dent', 'Beeblebrox', 'Prefect'], qtype=QSYMBOL_LIST), + qlist([98, 42, 126], qtype=QLONG_LIST)]), + qtable(qlist(['name', 'iq'], qtype=QSYMBOL_LIST), + [qlist(['Dent', 'Beeblebrox', 'Prefect']), + qlist([98, 42, 126])], + name=QSYMBOL, iq=QLONG), + qtable(['name', 'iq'], + [['Dent', 'Beeblebrox', 'Prefect'], + [98, 42, 126]], + name=QSYMBOL, iq=QLONG), + qtable(['name', 'iq'], + [['Dent', 'Beeblebrox', 'Prefect'], + [98, 42, 126]], + **{'name': QSYMBOL, 'iq': QLONG}))), + (b'flip `name`iq`grade!(`Dent`Beeblebrox`Prefect;98 42 126;"a c")', + qtable(qlist(numpy.array(['name', 'iq', 'grade']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype=QSYMBOL_LIST), + qlist(numpy.array([98, 42, 126]), + qtype=QLONG_LIST), + "a c"])), + (b'flip `name`iq`fullname!(`Dent`Beeblebrox`Prefect;98 42 126;("Arthur Dent"; "Zaphod Beeblebrox"; "Ford Prefect"))', + qtable(qlist(numpy.array(['name', 'iq', 'fullname']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype=QSYMBOL_LIST), + qlist(numpy.array([98, 42, 126]), + qtype=QLONG_LIST), + qlist(numpy.array(["Arthur Dent", "Zaphod Beeblebrox", "Ford Prefect"]), qtype=QSTRING_LIST)])), + (b'flip `name`iq`misc!(`Dent`Beeblebrox`Prefect;98 42 126;("The Hitch Hiker\'s Guide to the Galaxy"; 160; 1979.10.12))', + qtable(qlist(numpy.array(['name', 'iq', 'misc']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['Dent', 'Beeblebrox', 'Prefect']), qtype=QSYMBOL_LIST), + qlist(numpy.array([98, 42, 126]), + qtype=QLONG_LIST), + qlist(numpy.array(["The Hitch Hiker\'s Guide to the Galaxy", long(160), qtemporal(numpy.datetime64('1979-10-12', 'D'), qtype=QDATE)]), qtype=QGENERAL_LIST)])), + (b'([] sc:1 2 3; nsc:(1 2; 3 4; 5 6 7))', (qtable(qlist(numpy.array(['sc', 'nsc']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3], dtype=numpy.int64), qtype=QLONG_LIST), + [qlist(numpy.array([1, 2], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array( + [3, 4], dtype=numpy.int64), qtype=QLONG_LIST), + qlist(numpy.array([5, 6, 7], dtype=numpy.int64), qtype=QLONG_LIST)]]), + qtable(qlist(numpy.array(['sc', 'nsc']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3]), qtype=QLONG_LIST), + [qlist(numpy.array([1, 2]), qtype=QLONG_LIST), + qlist(numpy.array( + [3, 4]), qtype=QLONG_LIST), + qlist(numpy.array([5, 6, 7]), qtype=QLONG_LIST)]]), + qtable(qlist(['sc', 'nsc'], qtype=QSYMBOL_LIST), + [qlist([1, 2, 3], qtype=QLONG_LIST), + [qlist([1, 2], qtype=QLONG_LIST), + qlist( + [3, 4], qtype=QLONG_LIST), + qlist([5, 6, 7], qtype=QLONG_LIST)]]))), + (b'([] sc:1 2 3; nsc:(1 2; 3 4; 5 6))', qtable(qlist(numpy.array(['sc', 'nsc']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1, 2, 3]), qtype=QLONG_LIST), + [qlist(numpy.array([1, 2]), qtype=QLONG_LIST), + qlist(numpy.array( + [3, 4]), qtype=QLONG_LIST), + qlist(numpy.array([5, 6]), qtype=QLONG_LIST)]])), + (b'1#([] sym:`x`x`x;str:" a")', {'data': qtable(qlist(numpy.array(['sym', 'str']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['x'], dtype=numpy.string_), qtype=QSYMBOL_LIST), + b" "]), + 'single_char_strings': True + }), + (b'-1#([] sym:`x`x`x;str:" a")', {'data': qtable(qlist(numpy.array(['sym', 'str']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['x'], dtype=numpy.string_), qtype=QSYMBOL_LIST), + b"a"]), + 'single_char_strings': True + }), + (b'2#([] sym:`x`x`x`x;str:" aa")', qtable(qlist(numpy.array(['sym', 'str']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['x', 'x'], dtype=numpy.string_), qtype=QSYMBOL_LIST), + b" "])), + (b'-2#([] sym:`x`x`x`x;str:" aa")', qtable(qlist(numpy.array(['sym', 'str']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['x', 'x'], dtype=numpy.string_), qtype=QSYMBOL_LIST), + b"aa"])), + (b'([] name:`symbol$(); iq:`int$())', (qtable(qlist(numpy.array(['name', 'iq']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([], dtype=numpy.string_), qtype=QSYMBOL_LIST), + qlist(numpy.array([], dtype=numpy.int32), qtype=QINT_LIST)]), + qtable(qlist(numpy.array(['name', 'iq']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([]), qtype=QSYMBOL_LIST), + qlist(numpy.array([]), qtype=QINT_LIST)]), + qtable(qlist(['name', 'iq'], qtype=QSYMBOL_LIST), + [qlist([], qtype=QSYMBOL_LIST), + qlist([], qtype=QINT_LIST)]))), + (b'([] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))', + (qtable(qlist(numpy.array(['pos', 'dates']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['d1', 'd2', 'd3']), qtype=QSYMBOL_LIST), + qlist(numpy.array([366, 121, qnull(QDATE)]), qtype=QDATE_LIST)]), + qtable(['pos', 'dates'], + [qlist(numpy.array(['d1', 'd2', 'd3']), qtype=QSYMBOL_LIST), + numpy.array([numpy.datetime64('2001-01-01'), numpy.datetime64('2000-05-01'), numpy.datetime64('NaT')], dtype='datetime64[D]')]) + )), + (b'([eid:1001 1002 1003] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))', + QKeyedTable(qtable(qlist(numpy.array(['eid']), qtype=QSYMBOL_LIST), + [qlist(numpy.array([1001, 1002, 1003]), qtype=QLONG_LIST)]), + qtable(qlist(numpy.array(['pos', 'dates']), qtype=QSYMBOL_LIST), + [qlist(numpy.array(['d1', 'd2', 'd3']), qtype=QSYMBOL_LIST), + qlist(numpy.array([366, 121, qnull(QDATE)]), qtype=QDATE_LIST)])) + ), +)) def init(): - with open('tests/QExpressions3.out', 'rb') as f: + with open(os.path.join(TEST_DATA_DIR, 'QExpressions3.out'), 'rb') as f: while True: query = f.readline().strip() binary = f.readline().strip() @@ -352,37 +453,43 @@ def init(): BINARY[query] = binary - def test_writing(): w = qwriter.QWriter(None, 3) for query, value in iter(EXPRESSIONS.items()): - sys.stdout.write( '%-75s' % query ) + sys.stdout.write('%-75s' % query) if isinstance(value, tuple): for obj in value: - sys.stdout.write( '.' ) + sys.stdout.write('.') serialized = binascii.hexlify(w.write(obj, 1))[16:].lower() - assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % (query, BINARY[query].lower(), serialized) + assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % ( + query, BINARY[query].lower(), serialized) elif isinstance(value, dict): - sys.stdout.write( '.' ) + sys.stdout.write('.') single_char_strings = value['single_char_strings'] if 'single_char_strings' in value else False - serialized = binascii.hexlify(w.write(value['data'], 1, single_char_strings = single_char_strings))[16:].lower() - assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % (query, BINARY[query].lower(), serialized) + serialized = binascii.hexlify( + w.write(value['data'], 1, single_char_strings=single_char_strings))[16:].lower() + assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % ( + query, BINARY[query].lower(), serialized) else: - sys.stdout.write( '.' ) + sys.stdout.write('.') serialized = binascii.hexlify(w.write(value, 1))[16:].lower() - assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % (query, BINARY[query].lower(), serialized) + assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % ( + query, BINARY[query].lower(), serialized) print('') + def test_write_single_char_string(): w = qwriter.QWriter(None, 3) - for obj in (['one', 'two', '3'], qlist(['one', 'two', '3'], qtype = QSTRING_LIST)): + for obj in (['one', 'two', '3'], qlist(['one', 'two', '3'], qtype=QSTRING_LIST)): single_char_strings = False for query in (b'("one"; "two"; "3")', b'("one"; "two"; enlist "3")'): - serialized = binascii.hexlify(w.write(obj, 1, single_char_strings = single_char_strings ))[16:].lower() - assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % (query, BINARY[query].lower(), serialized) + serialized = binascii.hexlify( + w.write(obj, 1, single_char_strings=single_char_strings))[16:].lower() + assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % ( + query, BINARY[query].lower(), serialized) single_char_strings = not single_char_strings diff --git a/tests/QCompressedExpressions3.out b/tests/test_data/QCompressedExpressions3.out similarity index 100% rename from tests/QCompressedExpressions3.out rename to tests/test_data/QCompressedExpressions3.out diff --git a/tests/QExpressions3.out b/tests/test_data/QExpressions3.out similarity index 100% rename from tests/QExpressions3.out rename to tests/test_data/QExpressions3.out diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..1a0c0ae --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +@@ -0,0 +1,10 @@ +# content of: tox.ini , put in same dir as setup.py +[tox] +envlist = py310 + +[testenv] +# install pytest in the virtualenv where commands will be executed +deps = -r{toxinidir}/requirements.txt +commands = + # NOTE: you can run any command line tool here - not just tests + pytest --maxfail=100 --junit-xml test-reports/results.xml tests \ No newline at end of file