Skip to content

Commit 4601e45

Browse files
authored
Merge pull request #15 from IntuitionEngineeringTeam/bug_fix
Fix cython import
2 parents 6f7b7df + 10c34ed commit 4601e45

10 files changed

Lines changed: 71 additions & 25 deletions

File tree

MANIFEST.in

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
recursive-include ./core *
2-
recursive-include ./redblackpy *
3-
recursive-include ./benchmark *
4-
recursive-include ./series *
5-
recursive-include ./tree_cython_api *
6-
recursive-include ./setup_tools *
7-
recursive-include ./cython_source *
1+
recursive-include core/tree/ *.hpp *.tpp
2+
recursive-include core/trees_iterator/ *.hpp *.tpp
3+
recursive-include core/exceptions/ *.hpp
4+
recursive-include redblackpy/tree_cython_api/ *.pxd
5+

docs/doc_index.html

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,14 @@
475475
<body>
476476

477477
<div id="toc_container" style="position:fixed;width: 200px;left:1em;top:1em">
478-
<h3> <font color=#e2e6ee> RedBlackPy 0.1.0 </font> </h3>
478+
<h3> <font color=#e2e6ee> RedBlackPy 0.1.2 </font> </h3>
479479
<h4> <font color=#e2e6ee> Table of contents: </font> </h4>
480480
<div id="expanded" style="display: true">
481481
<a href="./index.html" class="button">Main</a> <br>
482482
<a href="./series.html" class="button">Series</a> <br>
483483
<a href="./series_user_guide.html" class="button">User Guide</a> <br>
484-
<a href="#no" class="button">Cython users</a> <br>
485-
<a href="#no" class="button">Contacts</a> <br>
484+
<a href="#cy" class="button">Cython users</a> <br>
485+
<a href="#con" class="button">Contacts</a> <br>
486486
</div>
487487

488488
<p></div>
@@ -508,10 +508,41 @@ <h5> 2. Via pip </h5>
508508
The first release is presented by two classes: Series and SeriesIterator. See documnetation and user guide for usage.</p>
509509

510510
<p><br>
511+
<a name = "cy"></a>
511512
<center> <h3>Cython Users</h3> </center>
512-
We have include pxd files for Cython users. See <a href="https://github.com/IntuitionEngineeringTeam/RedBlackPy/blob/master/redblackpy/series/tree_series.pxd">source</a>. </p>
513+
We have include pxd files for Cython users. See <a href="https://github.com/IntuitionEngineeringTeam/RedBlackPy/blob/master/redblackpy/series/tree_series.pxd">source</a>. To use Series class from Cython input the following imports in yours .pyx files:</p>
514+
515+
<div><pre><code class="language-python"># your_ex.pyx
516+
517+
from redblackpy.series.tree_series import Series
518+
from redblackpy.series.tree_series cimport Series
519+
520+
cpdef Series test():
521+
cdef Series myseries = Series()
522+
523+
myseries.insert(1,1)
524+
525+
return myseries</code></pre></div>
526+
527+
<p>Also, include necessary directories with .hpp headers to compile your extension module by adding <code>inclide_dirs</code> parameter in <code>Extension</code> object:</p>
528+
529+
<div><pre><code class="language-python"># setup.py
530+
531+
from setuptools import setup
532+
from distutils.extension import Extension
533+
from Cython.Build import cythonize
534+
import redblackpy as rb
535+
536+
ex = Extension( &quot;your_module.your_ex&quot;,
537+
sources=[&quot;your_module/your_ex.pyx&quot;],
538+
include_dirs=[rb.get_include()] )
539+
540+
setup( name=&#39;your_module&#39;,
541+
ext_modules = cythonize(ex) )
542+
</code></pre></div>
513543

514544
<p><br>
545+
<a name = "con"></a>
515546
<center> <h3>Contact us</h3> </center></p>
516547

517548
<p>Feel free to contact us about any questions. Website of our team <a href="https://intuition.engineering">IntuitionEngineering</a>.</p>
@@ -526,6 +557,10 @@ <h5> 2. Via pip </h5>
526557
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={util:{encode:function(e){return e instanceof a?new a(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function(e){var t=n.util.type(e);switch(t){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=n.util.clone(e[r]));return a;case"Array":return e.map&&e.map(function(e){return n.util.clone(e)})}return e}},languages:{extend:function(e,t){var a=n.util.clone(n.languages[e]);for(var r in t)a[r]=t[r];return a},insertBefore:function(e,t,a,r){r=r||n.languages;var l=r[e];if(2==arguments.length){a=arguments[1];for(var i in a)a.hasOwnProperty(i)&&(l[i]=a[i]);return l}var o={};for(var s in l)if(l.hasOwnProperty(s)){if(s==t)for(var i in a)a.hasOwnProperty(i)&&(o[i]=a[i]);o[s]=l[s]}return n.languages.DFS(n.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=o)}),r[e]=o},DFS:function(e,t,a,r){r=r||{};for(var l in e)e.hasOwnProperty(l)&&(t.call(e,l,e[l],a||l),"Object"!==n.util.type(e[l])||r[n.util.objId(e[l])]?"Array"!==n.util.type(e[l])||r[n.util.objId(e[l])]||(r[n.util.objId(e[l])]=!0,n.languages.DFS(e[l],t,l,r)):(r[n.util.objId(e[l])]=!0,n.languages.DFS(e[l],t,null,r)))}},plugins:{},highlightAll:function(e,t){var a={callback:t,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};n.hooks.run("before-highlightall",a);for(var r,l=a.elements||document.querySelectorAll(a.selector),i=0;r=l[i++];)n.highlightElement(r,e===!0,a.callback)},highlightElement:function(t,a,r){for(var l,i,o=t;o&&!e.test(o.className);)o=o.parentNode;o&&(l=(o.className.match(e)||[,""])[1],i=n.languages[l]),t.className=t.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,o=t.parentNode,/pre/i.test(o.nodeName)&&(o.className=o.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var s=t.textContent,u={element:t,language:l,grammar:i,code:s};if(!s||!i)return n.hooks.run("complete",u),void 0;if(n.hooks.run("before-highlight",u),a&&_self.Worker){var c=new Worker(n.filename);c.onmessage=function(e){u.highlightedCode=e.data,n.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(u.element),n.hooks.run("after-highlight",u),n.hooks.run("complete",u)},c.postMessage(JSON.stringify({language:u.language,code:u.code,immediateClose:!0}))}else u.highlightedCode=n.highlight(u.code,u.grammar,u.language),n.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(t),n.hooks.run("after-highlight",u),n.hooks.run("complete",u)},highlight:function(e,t,r){var l=n.tokenize(e,t);return a.stringify(n.util.encode(l),r)},tokenize:function(e,t){var a=n.Token,r=[e],l=t.rest;if(l){for(var i in l)t[i]=l[i];delete t.rest}e:for(var i in t)if(t.hasOwnProperty(i)&&t[i]){var o=t[i];o="Array"===n.util.type(o)?o:[o];for(var s=0;s<o.length;++s){var u=o[s],c=u.inside,g=!!u.lookbehind,h=!!u.greedy,f=0,d=u.alias;u=u.pattern||u;for(var p=0;p<r.length;p++){var m=r[p];if(r.length>e.length)break e;if(!(m instanceof a)){u.lastIndex=0;var y=u.exec(m),v=1;if(!y&&h&&p!=r.length-1){var b=r[p+1].matchedStr||r[p+1],k=m+b;if(p<r.length-2&&(k+=r[p+2].matchedStr||r[p+2]),u.lastIndex=0,y=u.exec(k),!y)continue;var w=y.index+(g?y[1].length:0);if(w>=m.length)continue;var _=y.index+y[0].length,P=m.length+b.length;if(v=3,P>=_){if(r[p+1].greedy)continue;v=2,k=k.slice(0,P)}m=k}if(y){g&&(f=y[1].length);var w=y.index+f,y=y[0].slice(f),_=w+y.length,S=m.slice(0,w),O=m.slice(_),j=[p,v];S&&j.push(S);var A=new a(i,c?n.tokenize(y,c):y,d,y,h);j.push(A),O&&j.push(O),Array.prototype.splice.apply(r,j)}}}}}return r},hooks:{all:{},add:function(e,t){var a=n.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=n.hooks.all[e];if(a&&a.length)for(var r,l=0;r=a[l++];)r(t)}}},a=n.Token=function(e,t,n,a,r){this.type=e,this.content=t,this.alias=n,this.matchedStr=a||null,this.greedy=!!r};if(a.stringify=function(e,t,r){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return a.stringify(n,t,e)}).join("");var l={type:e.type,content:a.stringify(e.content,t,r),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:r};if("comment"==l.type&&(l.attributes.spellcheck="true"),e.alias){var i="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}n.hooks.run("wrap",l);var o="";for(var s in l.attributes)o+=(o?" ":"")+s+'="'+(l.attributes[s]||"")+'"';return"<"+l.tag+' class="'+l.classes.join(" ")+'" '+o+">"+l.content+"</"+l.tag+">"},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,r=t.code,l=t.immediateClose;_self.postMessage(n.highlight(r,n.languages[a],a)),l&&_self.close()},!1),_self.Prism):_self.Prism;var r=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return r&&(n.filename=r.src,document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",n.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
527558
</script>
528559

560+
<script type="text/javascript">
561+
Prism.languages.python={"triple-quoted-string":{pattern:/"""[\s\S]+?"""|'''[\s\S]+?'''/,alias:"string"},comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/("|')(?:\\?.)*?\1/,"function":{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)[a-z0-9_]+/i,lookbehind:!0},keyword:/\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(?:True|False)\b/,number:/\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,punctuation:/[{}[\];(),.:]/};
562+
</script>
563+
529564
<script type="text/x-mathjax-config">
530565
(function () {
531566

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232
<div class="wrapper__body">
3333
<div class="wrapper__info">
34-
<h1>RedBlackPy v0.1.1</h1>
34+
<h1>RedBlackPy v0.1.2</h1>
3535
<div class="main-info">
3636
<p>Fast and scalable data structures for dynamic ordered data processing.</p>
3737
<p>RedBlackPy is a Python library built on red-black trees instead of hash-tables and arrays for convenient work with time series and scientific evaluations.</p>

docs/series.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
<body>
476476

477477
<div id="toc_container" style="position:fixed;width: 200px;left:1em;top:1em">
478-
<h3> <font color=#e2e6ee> RedBlackPy 0.1.0 </font> </h3>
478+
<h3> <font color=#e2e6ee> RedBlackPy 0.1.2 </font> </h3>
479479
<h4> <font color=#e2e6ee> Table of contents: </font> </h4>
480480
<div id="expanded" style="display: true">
481481
<a href="./doc_index.html" class="button">Main</a> <br>

docs/series_user_guide.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
<body>
476476

477477
<div id="toc_container" style="position:fixed;width: 200px;left:1em;top:1em">
478-
<h3> <font color=#e2e6ee> RedBlackPy 0.1.0 </font> </h3>
478+
<h3> <font color=#e2e6ee> RedBlackPy 0.1.2 </font> </h3>
479479
<h4> <font color=#e2e6ee> Table of contents: </font> </h4>
480480
<div id="expanded" style="display: true">
481481
<a href="./doc_index.html" class="button">Main</a> <br>

redblackpy/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
# Created by Soldoskikh Kirill.
33
# Copyright © 2018 Intuition. All rights reserved.
44
#
5-
5+
from os.path import dirname, abspath, join
66
from .series.tree_series import *
77
from .series.series_iterator import *
88
from .benchmark.timer import *
99

10-
__all__ = ['Series', 'SeriesIterator', 'Timer']
10+
__all__ = ['Series', 'SeriesIterator', 'Timer']
11+
12+
13+
def get_include():
14+
15+
return dirname(dirname(abspath(__file__)))
16+

redblackpy/cython_source/__tree_series_dtype.pxi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,10 @@ cdef class __TreeSeries_{DTYPE}(__BaseTreeSeries):
268268
self.insert( it[0], num )
269269

270270
elif to_type == "str":
271-
272271
for it in other.iteritems():
273272
self.insert( it[0], str(it[1]) )
274273

275274
else:
276-
277275
for it in other.iteritems():
278276
self.insert(it[0], it[1])
279277

@@ -608,7 +606,6 @@ cdef class __TreeSeries_{DTYPE}(__BaseTreeSeries):
608606
other.on_itermode()
609607

610608
while not iterator.empty():
611-
612609
key = <object>deref(iterator).key.data
613610
current = action(self.__getitem__(key), other[key])
614611
__insert_node_{DTYPE}(result.__index, key, current)

redblackpy/cython_source/c_pyobject.pxi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ cdef inline int compare_func(const c_pyobject& a_1, const c_pyobject& a_2) with
2828

2929
return PyObject_RichCompareBool(a_1.data, a_2.data, Py_LT)
3030

31+
3132
cdef inline int equal(const c_pyobject& a_1, const c_pyobject& a_2) with gil:
3233

3334
return PyObject_RichCompareBool(a_1.data, a_2.data, Py_EQ)
3435

36+
3537
cdef inline int comp_pair( const pair[rb_tree_ptr, iterator]& a_1,
3638
const pair[rb_tree_ptr, iterator]& a_2 ) with gil:
3739

redblackpy/series/tree_series.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ from libcpp.utility cimport pair
2424
from libcpp.vector cimport vector
2525
from ..tree_cython_api.types_mapping cimport *
2626
from ..tree_cython_api cimport tree as tree
27-
import pandas as pd
2827

2928
import cython
3029
cimport cython
@@ -802,6 +801,8 @@ cdef class Series:
802801
"""
803802
Convert to pandas.Series.
804803
"""
804+
import pandas as pd
805+
805806
return pd.Series( data=self.values(), index=self.index() )
806807

807808

@@ -811,6 +812,8 @@ cdef class Series:
811812
"""
812813
Initialize Series object from pandas.Series.
813814
"""
815+
import pandas as pd
816+
814817
cdef Series result = Series( index=pd_series.index,
815818
values=pd_series.data,
816819
dtype=str(pd_series.dtype),

setup.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,24 @@
9898

9999
setup( name='redblackpy',
100100
ext_modules = cythonize(ext_modules),
101-
version='0.1.1.0',
101+
version='0.1.2.0',
102102
author='Solodskikh Kirill',
103103
author_email='hypo@intuition.engineering',
104104
maintainer='Intuition',
105105
maintainer_email='dev@intuition.engineering',
106-
install_requires=['cython>=0.27', 'pandas'],
106+
install_requires=['cython>=0.27'],
107107
description='Data structures based on red-black trees.',
108108
url='https://intuitionengineeringteam.github.io/RedBlackPy/',
109109
download_url='https://github.com/IntuitionEngineeringTeam/RedBlackPy/archive/master.zip',
110110
zip_safe=False,
111-
packages=[ 'redblackpy', 'redblackpy.series',
112-
'redblackpy.benchmark', 'rbp_setup_tools' ],
113-
package_data={'redblackpy.series': ['*.pxd']},
111+
packages=[ '', 'redblackpy', 'redblackpy.series',
112+
'redblackpy.benchmark', 'redblackpy.tree_cython_api'],
113+
package_data={'redblackpy.series': ['*.pxd'],
114+
'': ['/core/tree/*.hpp',
115+
'/core/tree/*.tpp',
116+
'/core/trees_iterator/*.hpp',
117+
'/core/trees_iterator/*.tpp']},
118+
include_package_data=True,
114119
license='Apache License 2.0',
115120
long_description='RedBlackPy is a light Python library that provides data structures \
116121
aimed to fast insertion, removal and self sorting to manipulating ordered data in efficient way.\

0 commit comments

Comments
 (0)