Skip to content

Commit

Permalink
Documentation amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejlach committed Aug 4, 2015
1 parent 5f689dc commit 00bd374
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 171 deletions.
6 changes: 3 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ def __getattr__(cls, name):

# General information about the project.
project = u'qPython'
copyright = u'2014, DEVnet'
copyright = u'2014-2015, DEVnet'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
version = '1.1'
# The full version, including alpha/beta/rc tags.
release = '1.0-beta'
release = '1.1.0b1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
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))


Q parser 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
27 changes: 14 additions & 13 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 @@ -119,17 +119,18 @@ Both 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)]]
Expand Down
8 changes: 4 additions & 4 deletions doc/source/type-conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,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 @@ -203,11 +203,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 00bd374

Please sign in to comment.