django-matrix-field
===================
A Django app providing database and form fields for matrices (arrays of arrays).
Examples
--------
Database Field
~~~~~~~~~~~~~~
.. code:: python
from django.db import models
from matrix_field import MatrixField
class MyModel(models.Model):
matrix1 = MatrixField(datatype='float', dimensions=(3, 2))
matrix2 = MatrixField(datatype='str', dimensions=(2,))
my_inst = MyModel(
matrix1=[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]],
matrix2=['a list', 'of strings'],
)
my_inst.full_clean() # validates datatype, dimensions
my_inst.save() # values stored in DB as json
m1 = my_inst.matrix1 # values retrieved as matrices
repr(m1) # '[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]]'
Form Field
~~~~~~~~~~
.. code:: python
import json
from django import forms
from matrix_field import MatrixFormField
class MyForm(forms.Form):
matrix = MatrixFormField(datatype='int', dimensions=(2, 1))
my_form = MyForm({
'matrix': json.dumps([[2], [1]]), # assignment of json representation
})
my_form.full_clean() # validates datatype, dimensions
m = my_form.cleaned_data['matrix'] # values retrieved as matrices
repr(m) # '[[2], [1]]'
Found a Bug?
------------
To file a bug or submit a patch, please head over to `django-matrix-field on github`__.
__ https://github.com/Sharmaxz/django-matrix-field
Raw data
{
"_id": null,
"home_page": "http://github.com/mfogel/django-matrix-field/",
"name": "django-matrix-field",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Mike Fogel",
"author_email": "mike@fogel.ca",
"download_url": "https://files.pythonhosted.org/packages/5a/a4/9a74e9227cf7d6645defbd0f1455f2c6823010edb5bfca0dd900473f9c07/django_matrix_field-0.3.tar.gz",
"platform": null,
"description": "django-matrix-field\r\n===================\r\n\r\nA Django app providing database and form fields for matrices (arrays of arrays).\r\n\r\nExamples\r\n--------\r\n\r\nDatabase Field\r\n~~~~~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n from django.db import models\r\n from matrix_field import MatrixField\r\n\r\n class MyModel(models.Model):\r\n matrix1 = MatrixField(datatype='float', dimensions=(3, 2))\r\n matrix2 = MatrixField(datatype='str', dimensions=(2,))\r\n\r\n my_inst = MyModel(\r\n matrix1=[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]],\r\n matrix2=['a list', 'of strings'],\r\n )\r\n my_inst.full_clean() # validates datatype, dimensions\r\n my_inst.save() # values stored in DB as json\r\n\r\n m1 = my_inst.matrix1 # values retrieved as matrices\r\n repr(m1) # '[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]]'\r\n\r\n\r\nForm Field\r\n~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n import json\r\n from django import forms\r\n from matrix_field import MatrixFormField\r\n\r\n class MyForm(forms.Form):\r\n matrix = MatrixFormField(datatype='int', dimensions=(2, 1))\r\n\r\n my_form = MyForm({\r\n 'matrix': json.dumps([[2], [1]]), # assignment of json representation\r\n })\r\n my_form.full_clean() # validates datatype, dimensions\r\n\r\n m = my_form.cleaned_data['matrix'] # values retrieved as matrices\r\n repr(m) # '[[2], [1]]'\r\n\r\n\r\nFound a Bug?\r\n------------\r\n\r\nTo file a bug or submit a patch, please head over to `django-matrix-field on github`__.\r\n\r\n\r\n__ https://github.com/Sharmaxz/django-matrix-field\r\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "A Django app providing database and form fields for matrices (arrays of arrays).",
"version": "0.3",
"project_urls": {
"Homepage": "http://github.com/mfogel/django-matrix-field/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3ecfe6102789802631071cd0b268ab2745c90513d3997e661ea447f145c46538",
"md5": "5cd5a037cf1700ce7e21db06d0cbb19a",
"sha256": "a5a32d9c797991ef7bd6d551fa9e7769573e8db59ac74244702460576f3412fc"
},
"downloads": -1,
"filename": "django_matrix_field-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5cd5a037cf1700ce7e21db06d0cbb19a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8009,
"upload_time": "2024-05-15T23:44:10",
"upload_time_iso_8601": "2024-05-15T23:44:10.196512Z",
"url": "https://files.pythonhosted.org/packages/3e/cf/e6102789802631071cd0b268ab2745c90513d3997e661ea447f145c46538/django_matrix_field-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5aa49a74e9227cf7d6645defbd0f1455f2c6823010edb5bfca0dd900473f9c07",
"md5": "91bac78f94bd37c538ce9648b87454b1",
"sha256": "c1757a2592399053286d2ea18f2bc204a2c011efd445b1d14e9a20b690e42c47"
},
"downloads": -1,
"filename": "django_matrix_field-0.3.tar.gz",
"has_sig": false,
"md5_digest": "91bac78f94bd37c538ce9648b87454b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6779,
"upload_time": "2024-05-15T23:44:12",
"upload_time_iso_8601": "2024-05-15T23:44:12.342111Z",
"url": "https://files.pythonhosted.org/packages/5a/a4/9a74e9227cf7d6645defbd0f1455f2c6823010edb5bfca0dd900473f9c07/django_matrix_field-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-15 23:44:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mfogel",
"github_project": "django-matrix-field",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "django-matrix-field"
}