Skip to content

Commit

Permalink
PyQ Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pyq-enlnt committed Aug 30, 2017
1 parent 506362b commit 6d4403b
Show file tree
Hide file tree
Showing 59 changed files with 4,342 additions and 1,075 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ omit = */pyq/tests/*
tox =
src
.tox/*-numpy-*/lib/python*/site-packages
.tox/*-backtrace/lib/python*/site-packages

[report]
exclude_lines =
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ html/
.vscode/
.ipynb_checkpoints/

# workaround for #892
doc/0-9
doc/data
doc/xyz

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ include LICENSE.rst
include README.md
include src/pyq/_k.c
include src/pyq/mv.c
include src/pyq/k.h
include src/pyq/p.c
include src/pyq/py.c
include src/pyq/p.def
include src/pyq/p.k
include src/pyq/python.q
include src/pyq/pyq-operators.q
include src/pyq.c
include doc/*.rst
include src/pyq/kx/*
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
# PyQ
# PyQ - Python for kdb+

[![Documentation Status](https://readthedocs.org/projects/pyq/badge/?version=latest)](http://pyq.readthedocs.io/en/latest/?badge=latest)
[![PyPI Version](https://img.shields.io/pypi/v/pyq.svg)](https://pypi.python.org/pypi/pyq)

[PyQ][2] brings the [Python programming language][4] to the [kdb+ database][5]. It allows
developers to seamlessly integrate Python and q codes in one application.
This is achieved by bringing the Python and q interpreters in the same process
so that codes written in either of the languages operate on the same data.
In PyQ, Python and q objects live in the same memory space and share the same
data.

Quick install:
## Installation

```bash
pip install -i https://pypi.enlnt.com -U --no-binary pyq pyq
```

For detailed installation instructions see [installation instructions][1].

## Usage

Usage:
For Python programmers:

```
$ pyq
>>> from pyq import q
>>> 1 + q.til(10)
k('1 2 3 4 5 6 7 8 9 10')
```

or run your Python script as

```bash
pyq [python options] python-script
```

Documentation available on [https://pyq.enlnt.com][2] or via pydoc:
For q programmers:

```bash
pyq -m pydoc pyq
```
$ q
q)p)from math import hypot / prefix python code with p)
q)p)q.h = hypot / import a python function
q)h 3 4 / call the python function from q
5f
```

## Documentation

Test:
Documentation is available on the [PyQ homepage][2].

## Testing

Use [tox][3] to run tests.

Expand All @@ -33,7 +58,8 @@ cd path/to/pyq/source
tox
```


[1]: https://pyq.enlnt.com/install/install.html#installation
[2]: https://pyq.enlnt.com
[3]: https://tox.readthedocs.io/en/latest
[4]: https://www.python.org/about
[5]: https://kx.com
15 changes: 10 additions & 5 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/env bash

set -e
set -ex

export QHOME="/root/q"

echo "* Installing PyQ"

python setup.py install_exe
python setup.py install_qlib
python setup.py install_qext
python setup.py install_scripts
LDFLAGS='--coverage'
CFLAGS='-fno-strict-aliasing -g -O2 --coverage -fprofile-arcs -ftest-coverage'
LDFLAGS='--coverage -lgcov'
CFLAGS='--coverage'
export CFLAGS LDFLAGS
python setup.py install_lib
unset CFLAGS LDFLAGS
Expand All @@ -20,12 +21,16 @@ pyq --versions
echo "* Running tests"
pyq -mpytest --pyargs pyq
taskset -c "$CPUS" "${QHOME}/l${BITS}/q" src/pyq/tests/test.p
gcov_path=$(ls -1d build/temp*/src/pyq)
ls -la ${gcov_path}/*{gcno,gcda}

echo "* Running lcov"
gcov_path="$(find . -type f -name "*.gcno" -o -name "*.gcda" -exec dirname {} \; -quit)"
lcov --capture \
--directory "${gcov_path}" \
--output-file pyq.info \
--rc lcov_branch_coverage=1 \
--base-directory $(pwd)/src/pyq \
--no-external \
--derive-func-data
ls -la ${gcov_path}/*{gcno,gcda}
gcov -f -b -c -o "${gcov_path}" src/pyq/_k.c
find . -name \*gcov
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
try:
from pyq import __version__
except ImportError:
__version__ = '4.0.3'
__version__ = '4.1.0'


# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
15 changes: 15 additions & 0 deletions doc/im.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyq import q, K
from matplotlib import pyplot as plt

def read_image(path):
path = str(path).lstrip(':')
x = plt.imread(path)
return K(x)
r = q('{x enlist y}', read_image)
q.set('.im.read', r)

def save_image(path, image):
path = str(path).lstrip(':')
plt.imsave(path, image)
q.set('.im.save', save_image)
q).q.imsave:{.im.save(x;y)}
Binary file added doc/images/Lenna.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ See the :ref:`ipython section <ipython>` for details.
:name: mastertoc

whatsnew/4.0
whatsnew/4.1
install/install
User Guide <manual/pyq>
reference/pyq-auto
Expand Down
2 changes: 1 addition & 1 deletion doc/install/centos32on64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Enter the virtual environment that we created, confirm that we have a 32-bit Pyt
5. Download the 32-bit Linux x86 version of kdb+ from kx.com
............................................................

Download `kdb+ by following this link <http://kx.com/software-download.php>`_.
Download `kdb+ by following this link <https://kx.com/download/>`_.

Save downloaded file as `${HOME}/Work/linux-x86.zip`.

Expand Down
2 changes: 2 additions & 0 deletions doc/install/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ Install PyQ:
.. include:: centos32on64.rst

.. include:: ubuntu.rst

.. include:: macos.rst
81 changes: 81 additions & 0 deletions doc/install/macos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Installing PyQ on macOS
-----------------------

In order to use PyQ with the free 32-bit kdb+ on macOS, you need a 32-bit version of Python. Out of the box,
macOS Sierra and High Sierra come with a universal version of Python 2.7.10.

System Python 2
...............

Install virtualenv module:

.. code-block:: bash
$ pip install virtualenv
If your system, does not have pip installed, follow `pip installation guide <https://pip.pypa.io/en/stable/installing/>`_.

Create and activate virtual environment:

.. code-block:: bash
$ virtualenv ${HOME}/pyq2
$ source ${HOME}/pyq2/bin/activate
Download `kdb+ by following this link <https://kx.com/download/>`_ and save the downloaded file as `${HOME}/Downloads/macosx.zip`.

Install kdb+ and PyQ:

.. code-block:: bash
(pyq2) $ unzip ${HOME}/Downloads/macosx.zip -d ${VIRTUAL_ENV}
(pyq2) $ pip install -i https://pyq.enlnt.com --no-binary pyq pyq
PyQ is ready and can be launched:

.. code-block:: bash
(pyq2) $ pyq
Brewing Universal Python
........................

If you would like to use latest version of the Python 2.7 or Python 3, you will need to install it
using package manager `Homebrew <https://brew.sh/>`_.

1. Install Homebrew. Installation instructions are available at `Homebrew's website <https://brew.sh/>`_.
2. Install universal Python 2.7 and Python 3.6:

.. code-block:: bash
$ brew install --universal sashkab/python/python27 sashkab/python/python36
3. Install virtualenv package.

.. code-block:: bash
$ /usr/local/opt/pythonXY/bin/pythonX -mpip install -U virtualenv
`X` is major version of the Python, `Y` - minor, i.e. 2.7 or 3.6.

4. Create new virtual environment and activate it:

.. code-block:: bash
$ mkvirtualenv -p /usr/local/opt/pythonXY/bin/pythonX ${HOME}/pyq
$ source ${HOME}/pyq/bin/activate
5. Download `kdb+ by following this link <https://kx.com/download/>`_ and save the downloaded file as `${HOME}/Downloads/macosx.zip`.

6. Install kdb+ and PyQ:

.. code-block:: bash
(pyq) $ unzip ${HOME}/Downloads/macosx.zip -d ${VIRTUAL_ENV}
(pyq) $ pip install -i https://pyq.enlnt.com --no-binary pyq pyq
PyQ is ready and can be launched:

.. code-block:: bash
(pyq2) $ pyq
7 changes: 7 additions & 0 deletions doc/license/copyright.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ Copyright © 2003-2013 Alexander Belopolsky.
Copyright © 2013-2017 Enlightenment Research, LLC.

All rights reserved.


Notice
______

Files in the ``src/pyq/kx`` directory are Copyright © Kx Systems and distributed under
`Apache 2.0 license <https://github.com/KxSystems/kdb/blob/master/LICENSE>`_.
42 changes: 42 additions & 0 deletions doc/logo/logo-slides.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions doc/manual/pyq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ take a :class:`pathlib.Path` object
k('`:data')
>>> q.load(data_path)
k('`data')
>>> data_path.unlink()

It is not necessary to assign data to a global variable before saving it to a
file. We can save our 10 integers directly to a file using the
Expand All @@ -641,6 +642,8 @@ and read it back using the :func:`pyq.q.set <q.get>` function
>>> q.get(_)
k('0 1 2 3 4 5 6 7 8 9')

>>> pathlib.Path('0-9').unlink()

---------
K objects
---------
Expand Down
Loading

0 comments on commit 6d4403b

Please sign in to comment.