├── .coveragerc ├── .gitignore ├── .pre-commit-config.yaml ├── .prospector.yaml ├── CHANGELOG.rst ├── CONTRIBUTORS.rst ├── LICENSE ├── MANIFEST.in ├── README.rst ├── django_numpy ├── __init__.py ├── apps.py ├── fields.py └── settings.py ├── requirements.txt ├── setup.cfg ├── setup.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | omit = 4 | */settings/* 5 | *__init__.py 6 | *urls* 7 | .tox* 8 | *tests* 9 | */migrations/* 10 | *manage.py 11 | *wsgi.py 12 | *celery.py 13 | 14 | [report] 15 | exclude_lines = 16 | # Don't complain if tests don't hit defensive assertion code: 17 | raise AssertionError 18 | raise NotImplementedError 19 | 20 | # Don't complain if non-runnable code isn't run: 21 | if 0: 22 | if __name__ == .__main__.: 23 | 24 | # Don't complain about missing debug-only code: 25 | def __repr__ 26 | if self\.debug 27 | if settings\.DEBUG 28 | 29 | ignore_errors = True 30 | 31 | [paths] 32 | source = 33 | ./ 34 | 35 | [html] 36 | directory = .coverage_report/html 37 | 38 | [xml] 39 | output = .coverage_report/coverage.xml 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | env/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | *dist/ 29 | *vendor/ 30 | status/static/status/ 31 | node_modules/ 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .coverage_report/ 47 | .coverage.* 48 | .coverage 49 | .cache 50 | nosetests.xml 51 | coverage.xml 52 | *,cover 53 | .unittests_report/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | static/ 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # PyCharm 70 | .idea/ 71 | 72 | # Celery 73 | celerybeat* 74 | celeryev* 75 | *.pid 76 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | - repo: git@github.com:pre-commit/pre-commit-hooks 2 | sha: 18d7035de5388cc7775be57f529c154bf541aab9 3 | hooks: 4 | - id: check-added-large-files 5 | - id: check-merge-conflict 6 | - id: check-xml 7 | - id: check-yaml 8 | - id: debug-statements 9 | - id: double-quote-string-fixer 10 | - id: end-of-file-fixer 11 | - id: fix-encoding-pragma 12 | - id: name-tests-test 13 | args: 14 | - --django 15 | - id: pretty-format-json 16 | args: 17 | - --autofix 18 | - --indent=2 19 | - id: requirements-txt-fixer 20 | - id: trailing-whitespace 21 | - repo: git://github.com/guykisel/prospector-mirror 22 | sha: 00fbd80101566b1b9c873c71f2ab7b95b8bd0a7d 23 | hooks: 24 | - id: prospector 25 | args: 26 | - --profile-path=.prospector.yaml 27 | -------------------------------------------------------------------------------- /.prospector.yaml: -------------------------------------------------------------------------------- 1 | output-format: grouped 2 | 3 | strictness: high 4 | test-warnings: false 5 | doc-warnings: false 6 | autodetect: true 7 | member-warnings: false 8 | 9 | ignore-paths: 10 | - docs 11 | - demo 12 | - build 13 | 14 | ignore-patterns: 15 | - .*\.feature$ 16 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | Changes 2 | ======= 3 | v0.1.0 - 20/10/2016 4 | * Initial release. 5 | -------------------------------------------------------------------------------- /CONTRIBUTORS.rst: -------------------------------------------------------------------------------- 1 | Contributors 2 | ============ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Django DjangoNumpy is a application for Django projects that provides an API to check the status of some parts and some utilities like ping requests. 2 | Copyright (C) 2015 Jose Antonio Perdiguero Lopez 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include CHANGELOG 3 | include README.rst 4 | include CONTRIBUTORS.rst 5 | include requirements.txt 6 | recursive-include django_numpy * 7 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Django Numpy 3 | ============ 4 | 5 | :Version: 1.0.1 6 | :DjangoNumpy: Production/Stable 7 | :Author: José Antonio Perdiguero López 8 | 9 | Django Numpy is an application for Django projects that adds some utilities and integration tools with Numpy. 10 | 11 | Quick start 12 | =========== 13 | 14 | #. Install this package using pip:: 15 | 16 | pip install django-numpy 17 | 18 | #. Add *PROJECT_PATH* to your django settings module. 19 | #. Add *status* to your **INSTALLED_APPS** settings like this:: 20 | 21 | INSTALLED_APPS = ( 22 | ... 23 | 'django_numpy', 24 | ) 25 | 26 | Database Fields 27 | =============== 28 | 29 | This package adds a new Field type that manages numpy arrays. This field is based on django ArrayField, that 30 | *only works with PostgreSQL backend*. The **NumpyArrayField** behave just like Django's ArrayField so all parameters 31 | defined in `official docs `_. 32 | -------------------------------------------------------------------------------- /django_numpy/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Django DjangoNumpy application. 4 | """ 5 | __version__ = '1.0.1' 6 | __license__ = 'GPLv3' 7 | 8 | __author__ = 'José Antonio Perdiguero López' 9 | __email__ = 'perdy.hh@gmail.com' 10 | 11 | __url__ = 'https://github.com/PeRDy/django-numpy' 12 | __description__ = 'Application for Django projects that adds some utilities and integration tools with Numpy.' 13 | 14 | default_app_config = 'django_numpy.apps.DjangoNumpy' 15 | -------------------------------------------------------------------------------- /django_numpy/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Django application config module. 3 | """ 4 | 5 | from django.apps import AppConfig 6 | from django.utils.translation import ugettext_lazy as _ 7 | 8 | 9 | class DjangoNumpy(AppConfig): 10 | name = 'django_numpy' 11 | verbose_name = _('Django Numpy') 12 | -------------------------------------------------------------------------------- /django_numpy/fields.py: -------------------------------------------------------------------------------- 1 | from django.contrib.postgres.fields import ArrayField 2 | 3 | try: 4 | from numpy import array 5 | except ImportError: 6 | array = list 7 | 8 | 9 | class NumpyArrayField(ArrayField): 10 | def __init__(self, base_field, size=None, **kwargs): 11 | super(NumpyArrayField, self).__init__(base_field, size, **kwargs) 12 | 13 | @property 14 | def description(self): 15 | return 'Numpy array of %s' % self.base_field.description 16 | 17 | def get_db_prep_value(self, value, connection, prepared=False): 18 | return super(NumpyArrayField, self).get_db_prep_value(list(value), connection, prepared) 19 | 20 | def deconstruct(self): 21 | name, path, args, kwargs = super(NumpyArrayField, self).deconstruct() 22 | kwargs.update({ 23 | 'base_field': self.base_field, 24 | 'size': self.size, 25 | }) 26 | return name, path, args, kwargs 27 | 28 | def to_python(self, value): 29 | return super(NumpyArrayField, self).to_python(array(value)) 30 | 31 | def value_to_string(self, obj): 32 | return super(NumpyArrayField, self).value_to_string(list(obj)) 33 | -------------------------------------------------------------------------------- /django_numpy/settings.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Settings. 4 | """ 5 | 6 | from django.conf import settings 7 | 8 | # Django debug settings. 9 | DEBUG = getattr(settings, 'DEBUG', False) 10 | 11 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django>=1.8 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.rst 3 | 4 | [wheel] 5 | universal = 1 6 | 7 | [coverage:run] 8 | source = . 9 | branch = True 10 | omit = 11 | *settings* 12 | *__init__.py 13 | *urls* 14 | .tox* 15 | *tests* 16 | */migrations/* 17 | */features/* 18 | *manage.py 19 | *wsgi.py 20 | *celery.py 21 | */apps.py 22 | run* 23 | 24 | [coverage:report] 25 | show_missing = True 26 | ignore_errors = True 27 | fail_under = 90 28 | exclude_lines = 29 | # Pragma 30 | pragma: no cover 31 | 32 | # Don't complain if tests don't hit defensive assertion code: 33 | raise AssertionError 34 | raise NotImplementedError 35 | 36 | # Don't complain if non-runnable code isn't run: 37 | if 0: 38 | if __name__ == .__main__.: 39 | 40 | # Don't complain about missing debug-only code: 41 | def __repr__ 42 | if self\.debug 43 | if settings\.DEBUG 44 | 45 | [coverage:paths] 46 | source = ./ 47 | 48 | [coverage:html] 49 | directory = .ci_report/coverage_html/ 50 | 51 | [coverage:xml] 52 | output = .ci_report/coverage.xml 53 | 54 | [pep8] 55 | max-line-length = 120 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from pathlib import Path 4 | import sys 5 | 6 | import pkg_resources 7 | from setuptools import setup 8 | 9 | import django_numpy 10 | 11 | 12 | BASE_DIR = Path(__file__).parent 13 | 14 | if sys.version_info[0] == 2: 15 | from codecs import open 16 | 17 | # Read requirements 18 | with (BASE_DIR / "requirements.txt").open() as requirements_txt: 19 | _REQUIRES = [ 20 | str(requirement) 21 | for requirement 22 | in pkg_resources.parse_requirements(requirements_txt) 23 | ] 24 | 25 | # Read description 26 | with open(BASE_DIR / "README.rst", encoding='utf-8') as f: 27 | _LONG_DESCRIPTION = f.read() 28 | 29 | _CLASSIFIERS = ( 30 | 'Development Status :: 5 - Production/Stable', 31 | 'Framework :: Django', 32 | 'Intended Audience :: Developers', 33 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 34 | 'Natural Language :: English', 35 | 'Programming Language :: Python', 36 | 'Programming Language :: Python :: 2', 37 | 'Programming Language :: Python :: 3', 38 | 'Topic :: Software Development :: Libraries :: Python Modules', 39 | ) 40 | _KEYWORDS = ' '.join([ 41 | 'python', 42 | 'django', 43 | 'database', 44 | 'numpy', 45 | ]) 46 | 47 | setup( 48 | name='django-numpy', 49 | version=django_numpy.__version__, 50 | description=django_numpy.__description__, 51 | long_description=_LONG_DESCRIPTION, 52 | author=django_numpy.__author__, 53 | author_email=django_numpy.__email__, 54 | maintainer=django_numpy.__author__, 55 | maintainer_email=django_numpy.__email__, 56 | url=django_numpy.__url__, 57 | download_url=django_numpy.__url__, 58 | packages=[ 59 | 'django_numpy', 60 | ], 61 | include_package_data=True, 62 | install_requires=_REQUIRES, 63 | extras_require={ 64 | 'dev': [ 65 | 'setuptools', 66 | 'pip', 67 | 'wheel', 68 | 'prospector' 69 | ] 70 | }, 71 | license=django_numpy.__license__, 72 | zip_safe=False, 73 | keywords=_KEYWORDS, 74 | classifiers=_CLASSIFIERS, 75 | ) 76 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py35-django{18,19,110} 3 | 4 | [testenv] 5 | deps = 6 | django18: Django==1.8 7 | django19: Django==1.9 8 | django110: Django==1.10 9 | -r{toxinidir}/requirements_base.txt 10 | -r{toxinidir}/requirements_test.txt 11 | setenv = 12 | PYTHONPATH = {toxinidir} 13 | DJANGO_SETTINGS_MODULE = tests.settings 14 | --------------------------------------------------------------------------------