From 4e96f5e224b7b3e8d94217ce91799f807c379f6c Mon Sep 17 00:00:00 2001 From: Agrimagsrl Date: Thu, 28 Nov 2019 21:05:26 +0100 Subject: [PATCH] fix setup --- MANIFEST.in | 1 - .../__pycache__/micromlgen.cpython-36.pyc | Bin 0 -> 1240 bytes micromlgen/micromlgen.py | 7 +++++-- micromlgen/templates/svm.jinja | 16 ++++++++-------- setup.py | 11 +++++++---- 5 files changed, 20 insertions(+), 15 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 micromlgen/__pycache__/micromlgen.cpython-36.pyc diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1ad14f6..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include micromlgen/templates/* \ No newline at end of file diff --git a/micromlgen/__pycache__/micromlgen.cpython-36.pyc b/micromlgen/__pycache__/micromlgen.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d0617ff264ca4c5e07e1f712a32668fcaaed01d GIT binary patch literal 1240 zcmZuw&2HO95a#kvB=r*|O`N8^s4Y-{Jy?NzD~h6mOs7U{$*`OtUAQ1v?Mfz1E`{Bd zQyJ8y>a}ms7w9W3dMMCS4t;^1I!h_84<#|f`DS-G-+ml^*=`31pa1#8-?m}=W!$?g zh`$9BUx6bALAimqPlOR*GdBwhTS(`u+%6pK6fSlFyTm5WF9465Gj9_ zOl8T_Bo9s1JxX&rSqVvtlQJQct7gP*QeLuxGC9@V^%a0U1bYc4{s1S9%GjU`5p->e zJ!ukigMLPpky&dSyfz2S1#3vJvWfK!_UowjM&`pa09;2KROt#ItO?et5YH;4YnVw4 zKtBPpcgQ4;Y^R90zjfD+>|_tJZtWk+M;o+3Ygc|yxf_HG`M7dP<0Bp}Vo-&kwE@Ne<=QQDLU)&V?knN?S zCzgvv$t5MdS;>2>e9IAN@=iPDQ?@K9Pb3YyxcM?VA4Mne#rJ0sZtcK}!RhJXZfQ7< zj&OUobQrxjk6`CfG`M(m9!=uI<5S#z9StwW=aYCiel@zl?cvE_GJ&-%d~g^Ik0;0D z(JrC<9lQ7j`z+o89HdNAKBWsOurn>`Oepk5p_THcc_KuSEEGDr4f-$$iyX)cm=rg! zN8;AkN6%80CAW=Bb}7ENWC{i0N6MC~1yx=gv!tMLtU3cBD3@u;BF;;WyLVKm9yt+X z_nLA>bLGsFqDZz(o-3EoIj2-vIb}GwBOP-S6un11#sOI-d93-zyrJbbOQGyVBCk|~ zq+Ih*9;ZoOr-0cE<{Owf3l0KsJpH)I#PCcTfkJX3Kh9XS*ms9g}|sRiQZ=g&uzbA^#YhvI~8JT6VYo;s^g}R#()= axaU6ARo>S{NtQYNM*jgqtK)4uS^omGVp$ph literal 0 HcmV?d00001 diff --git a/micromlgen/micromlgen.py b/micromlgen/micromlgen.py index fe26439..010f256 100644 --- a/micromlgen/micromlgen.py +++ b/micromlgen/micromlgen.py @@ -1,3 +1,4 @@ +import os import re from math import factorial from jinja2 import FileSystemLoader, Environment @@ -26,8 +27,10 @@ def port(clf, test_set=None, classmap=None, **kwargs): 'enumerate': enumerate, } } - loader = FileSystemLoader('.') - template = Environment(loader=loader).get_template('./templates/svm.jinja') + dir_path = os.path.dirname(os.path.realpath(__file__)) + print(dir_path) + loader = FileSystemLoader(dir_path + '/templates') + template = Environment(loader=loader).get_template('svm.jinja') code = template.render(template_data) code = re.sub(r'\n\s*\n', '\n', code) diff --git a/micromlgen/templates/svm.jinja b/micromlgen/templates/svm.jinja index ddb4107..bd27038 100644 --- a/micromlgen/templates/svm.jinja +++ b/micromlgen/templates/svm.jinja @@ -1,6 +1,6 @@ #pragma once -{% include 'templates/kernel_function.jinja' %} +{% include 'kernel_function.jinja' %} /** * Predict class for features vector @@ -10,16 +10,16 @@ int predict(double *x) { double decisions[{{ DECISIONS_COUNT }}] = { 0 }; int votes[{{ CLASSES_COUNT }}] = { 0 }; - {% include 'templates/compute_kernels.jinja' %} + {% include 'compute_kernels.jinja' %} {% if CLASSES_COUNT == 2 %} - {% include 'templates/binary_classification.jinja' %} + {% include 'binary_classification.jinja' %} {% else %} - {% include 'templates/compute_decisions.jinja' %} - {% include 'templates/compute_votes.jinja' %} - {% include 'templates/compute_class.jinja' %} + {% include 'compute_decisions.jinja' %} + {% include 'compute_votes.jinja' %} + {% include 'compute_class.jinja' %} {% endif %} } -{% include 'templates/self_test.jinja' %} -{% include 'templates/classmap.jinja' %} +{% include 'self_test.jinja' %} +{% include 'classmap.jinja' %} diff --git a/setup.py b/setup.py index f45fbfb..ef7267b 100644 --- a/setup.py +++ b/setup.py @@ -2,17 +2,20 @@ setup( name = 'micromlgen', packages = ['micromlgen'], - version = '0.4', + version = '0.5', license='MIT', description = 'Generate C code for microcontrollers from Python\'s sklearn classifiers', author = 'Simone Salerno', author_email = 'web@agrimag.it', url = 'https://github.com/agrimagsrl/micromlgen', - download_url = 'https://github.com/agrimagsrl/micromlgen/archive/v_04.tar.gz', + download_url = 'https://github.com/agrimagsrl/micromlgen/archive/v_05.tar.gz', keywords = ['ML', 'microcontrollers', 'sklearn', 'machine learning'], install_requires=[ - 'jinja2', - ], + 'jinja2', + ], + package_data= { + 'micromlgen': ['templates/*.jinja'] + }, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers',