Skip to main content

Cythonize modelx models.

Project description

modelx-cython: Cythonize modelx models

Important: modelx-cython is currently highly experimental and is released only for early adopters with advanced software engineering skills to explore its capability.

What is modelx-cython?

modelx-cython is a Python package for cythonizing exported modelx models.

modelx Ecosystem

Usage

Suppose model in the code below is a modelx Model. The code creates a pure-Python model of model as a Python package named "Model_nomx" in the current directory.

>>> model.export("Model_nomx")

You need a config file and a sample file to translate the model to a Cythonized model and compile it. Create and name them config.py and sample.py respectively, and place them in the directory where Model_nomx is located.

Upon installing modelx-cython, the mx2cy command becomes available as an executable command. In a Python-enabled command prompt or shell, change the current directory with cd to where Model_nomx is located, and run:

mx2cy Model_nomx

This will create a Python package named "Model_nomx_cy", next to the original "Model_nomx".

Command

usage: mx2cy [-h] [--sample SAMPLE] [--spec SPEC] [--setup SETUP] [--translate-only | --compile-only] model_path

Translate an exported modelx model into Cython and compile it.

positional arguments:
  model_path        Path to an exported modelx model to translate into Cython

options:
  -h, --help        show this help message and exit
  --sample SAMPLE   Path to a sample file to run for collecting type information (default: sample.py)
  --spec SPEC       Path to a spec file for setting parameters (default: spec.py)
  --setup SETUP     Path to a setup file for Cython (default: setup.py)
  --translate-only  Perform translation only (default: False)
  --compile-only    Perform compilation only (default: False)

See Also

How to Install

To install modelx-cython, run the following command from your command prompt:

pip install modelx-cython

If you're on Anaconda, modelx-cython will be available on conda-forge soon. For now, you can install it using pip. To avoid having modelx-cython install dependent packages from PyPI, install the dependent packages separately, and install modelx-cython with pip using the --no-deps option. Among the dependent packages, aside from modelx, only MonkeyType is not installed by default in most conda environments. So, install it from conda-forge:

conda install -c conda-forge monkeytype
pip install --no-deps modelx-cython

Requirements

modelx-cython requires Python 3.7+.

  • modelx v0.23.0+
  • Cython v3.0.0+
  • setuptools
  • libcst
  • MonkeyType

License

Copyright 2023, Fumito Hamamura

modelx is free software; you can redistribute it and/or modify it under the terms of GNU Lesser General Public License v3 (LGPLv3).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelx-cython-0.0.3.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

modelx_cython-0.0.3-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file modelx-cython-0.0.3.tar.gz.

File metadata

  • Download URL: modelx-cython-0.0.3.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for modelx-cython-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7162e4762e594b18c6cfd2b74664c0669c27cd8eb2836fbe031b00bbb51e5575
MD5 277b5c6fc6c2527e5026f5382838266b
BLAKE2b-256 5eb30a37fe17e0631237dbd9d87173f696b438ad45c629a2aaa3d10e2919c15a

See more details on using hashes here.

File details

Details for the file modelx_cython-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for modelx_cython-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7532974c653334ead63c7e0f09e17f624ba3a6e7a7f11c0bea2475fa366a0e87
MD5 d9e9baeef7a84d26ab7b61192522ace5
BLAKE2b-256 fff49a6e1a24ce4f8b0e0e3dc7c5aecf8d71a04e16be836a87a866e11f0f6b55

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page