Skip to content

Commit

Permalink
Merge pull request #34 from exxeleron/qpython-1.1-dev
Browse files Browse the repository at this point in the history
qpython 1.1
  • Loading branch information
maciejlach committed Nov 25, 2015
2 parents 72b874d + 48bba4a commit 52557d4
Show file tree
Hide file tree
Showing 28 changed files with 902 additions and 836 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: python

sudo: false

python:
- "2.7"
- "3.3"
- "3.4"

# command to install dependencies
install: pip install -r requirements.txt -U
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
------------------------------------------------------------------------------
qPython 1.1.0 [2015.11.25]
------------------------------------------------------------------------------

- Compatibility with Python 2.7, 3.3, and 3.4

------------------------------------------------------------------------------
qPython 1.0.2 [2015.09.03]
------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ qPython is a Python library providing support for interprocess communication bet
- Support for kdb+ protocol and types: v3.0, v2.6, v<=2.5
- Uncompression of the IPC data stream
- Internal representation of data via numpy arrays (lists, complex types) and numpy data types (atoms)
- Supported on Python 2.7 and numpy 1.8
- Supported on Python 2.7/3.3/3.4 and numpy 1.8

For more details please refer to the `documentation`_.

Expand Down
2 changes: 1 addition & 1 deletion conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: qpython
version: 1.0.2
version: "1.1.0"

build:
number: 1
Expand Down
4 changes: 2 additions & 2 deletions doc/source/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ can be used with a ``with`` statement:
::

with qconnection.QConnection(host = 'localhost', port = 5000) as q:
print q
print q('{`int$ til x}', 10)
print(q)
print(q('{`int$ til x}', 10))


Types conversion configuration
Expand Down
16 changes: 8 additions & 8 deletions doc/source/pandas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ For example:

>>> with qconnection.QConnection(host = 'localhost', port = 5000, pandas = True) as q:
>>> ds = q('(1i;0Ni;3i)', pandas = True)
>>> print ds
>>> print(ds)
0 1
1 NaN
2 3
dtype: float64
>>> print ds.meta
>>> print(ds.meta)
metadata(qtype=6)

>>> df = q('flip `name`iq`fullname!(`Dent`Beeblebrox`Prefect;98 42 126;("Arthur Dent"; "Zaphod Beeblebrox"; "Ford Prefect"))')
>>> print df
>>> print(df)
name iq fullname
0 Dent 98 Arthur Dent
1 Beeblebrox 42 Zaphod Beeblebrox
2 Prefect 126 Ford Prefect
>>> print df.meta
>>> print(df.meta)
metadata(iq=7, fullname=0, qtype=98, name=11)
>>> print q('type', df)
>>> print(q('type', df))
98

>>> df = q('([eid:1001 0N 1003;sym:`foo`bar`] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))')
>>> print df
>>> print(df)
pos dates
eid sym
1001 foo d1 2001-01-01
NaN bar d2 2000-05-01
1003 d3 NaT
>>> print df.meta
>>> print(df.meta)
metadata(dates=14, qtype=99, eid=7, sym=11, pos=11)
>>> print q('type', df)
>>> print(q('type', df))
99


Expand Down
33 changes: 17 additions & 16 deletions doc/source/queries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ Synchronous queries

Executes a q expression:

>>> print q.sync('til 10')
>>> print(q.sync('til 10'))
[0 1 2 3 4 5 6 7 8 9]

Executes an anonymous q function with a single parameter:

>>> print q.sync('{til x}', 10)
>>> print(q.sync('{til x}', 10))
[0 1 2 3 4 5 6 7 8 9]

Executes an anonymous q function with two parameters:

>>> print q.sync('{y + til x}', 10, 1)
>>> print(q.sync('{y + til x}', 10, 1))
[ 1 2 3 4 5 6 7 8 9 10]
>>> print q.sync('{y + til x}', *[10, 1])
>>> print(q.sync('{y + til x}', *[10, 1]))
[ 1 2 3 4 5 6 7 8 9 10]

The :class:`.QConnection` class implements the
:func:`~qpython.qconnection.QConnection.__call__` method. This allows
:class:`.QConnection` instance to be called as a function:

>>> print q('{y + til x}', 10, 1)
>>> print(q('{y + til x}', 10, 1))
[ 1 2 3 4 5 6 7 8 9 10]


Expand Down Expand Up @@ -84,25 +84,25 @@ For example:
- Retrieves query result along with meta-information:

>>> q.query(qconnection.MessageType.SYNC,'{x}', 10)
>>> print q.receive(data_only = False, raw = False)
>>> print(q.receive(data_only = False, raw = False))
QMessage: message type: 2, data size: 13, is_compressed: False, data: 10

- Retrieves parsed query result:

>>> q.query(qconnection.MessageType.SYNC,'{x}', 10)
>>> print q.receive(data_only = True, raw = False)
>>> print(q.receive(data_only = True, raw = False))
10

>>> q.sync('asynchMult:{[a;b] res:a*b; (neg .z.w)(res) }');
>>> q.sync('asynchMult:{[a;b] res:a*b; (neg .z.w)(res) }')
>>> q.async('asynchMult', 2, 3)
>>> print q.receive()
>>> print(q.receive())
6

- Retrieves not-parsed (raw) query result:

>>> from binascii import hexlify
>>> q.query(qconnection.MessageType.SYNC,'{x}', 10)
>>> print hexlify(q.receive(data_only = True, raw = True))
>>> print(hexlify(q.receive(data_only = True, raw = True)))
fa0a000000


Expand All @@ -120,24 +120,25 @@ These methods accepts the `options` keywords arguments::
>>> query = "{[x] 0Nd, `date$til x}"
>>> # retrieve function call as raw byte buffer
>>> print binascii.hexlify(q(query, 5, raw = True))
>>> from binascii import hexlify
>>> print(binascii.hexlify(q(query, 5, raw = True)))
0e0006000000000000800000000001000000020000000300000004000000

>>> # perform a synchronous call and parse dates vector to numpy array
>>> print q.sync(query, 5, numpy_temporals = True)
>>> print(q.sync(query, 5, numpy_temporals = True))
['NaT' '2000-01-01' '2000-01-02' '2000-01-03' '2000-01-04' '2000-01-05']

>>> # perform a synchronous call
>>> q.query(qconnection.MessageType.SYNC, query, 3)
>>> # retrieve query result and represent dates vector as raw data wrapped in QTemporalList
>>> print q.receive(numpy_temporals = False)
>>> print(q.receive(numpy_temporals = False))
[NaT [metadata(qtype=-14)] 2000-01-01 [metadata(qtype=-14)]
2000-01-02 [metadata(qtype=-14)] 2000-01-03 [metadata(qtype=-14)]]
>>> # serialize single element strings as q characters
>>> print q.sync('{[x] type each x}', ['one', 'two', '3'], single_char_strings = False)
>>> print(q.sync('{[x] type each x}', ['one', 'two', '3'], single_char_strings = False))
[ 10, 10, -10]
>>> # serialize single element strings as q strings
>>> print q.sync('{[x] type each x}', ['one', 'two', '3'], single_char_strings = True)
[10, 10, 10]
>>> print(q.sync('{[x] type each x}', ['one', 'two', '3'], single_char_strings = True))
[10, 10, 10]
8 changes: 4 additions & 4 deletions doc/source/type-conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ for ``month``\s etc.) and provides accessors which allow to convert raw data to
::

>>> v = q.sync("2001.01.01 2000.05.01 0Nd", numpy_temporals = False)
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
>>> print('%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v))
<class 'qpython.qcollection.QTemporalList'> dtype: int32 qtype: -14: [2001-01-01 [metadata(qtype=-14)] 2000-05-01 [metadata(qtype=-14)]
NaT [metadata(qtype=-14)]]
>>> v = q.sync("2000.01.04D05:36:57.600 0Np", numpy_temporals = False)
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
>>> print('%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v))
<class 'qpython.qcollection.QTemporalList'> dtype: int64 qtype: -12: [2000-01-04T05:36:57.600000000+0100 [metadata(qtype=-12)]
NaT [metadata(qtype=-12)]]

Expand All @@ -221,11 +221,11 @@ via :class:`~.qconnection.QConnection` constructor or as parameter to functions:
::
>>> v = q.sync("2001.01.01 2000.05.01 0Nd", numpy_temporals = True)
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
>>> print('%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v))
<class 'qpython.qcollection.QList'> dtype: datetime64[D] qtype: -14: ['2001-01-01' '2000-05-01' 'NaT']
>>> v = q.sync("2000.01.04D05:36:57.600 0Np", numpy_temporals = True)
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
>>> print('%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v))
<class 'qpython.qcollection.QList'> dtype: datetime64[ns] qtype: -12: ['2000-01-04T05:36:57.600000000+0100' 'NaT']

Expand Down
Loading

0 comments on commit 52557d4

Please sign in to comment.