Skip to main content

PDF, a visualisation of your calculation, can have essentials of your code.

Project description

PyLog2PDF

PyPI Python Test License

PDF, a visualisation of your calculation, can have essentials of your code.

Features

This library provides:

  • Log of Python classes and/or functions you employed.
  • Interface to save the log to PDF file.

Installation

pip install pylog2pdf

Usage

Log your classes and/or functions

>>> from pylog2pdf import LoggedClass, LoggedFunction

# Define your class or function with decorator
>>> @LoggedClass
... class MyNewClass:
...     pass

>>> @LoggedFunction
... def my_new_function():
...     pass

# Or using them as normal functions
>>> OtherLoggedClass = LoggedClass(OtherClass)
>>> other_logged_function = LoggedFunction(other_function)

I strongly recommend the use of class inheritance like the following. It's quite useful when determining which parameter is employed in calculation.

@LoggedClass
class Sun:

    distance: u.Quantity
    radius: u.Quantity

    def some_calculation(self, ...):
        pass

    def other_calculation(self, ...):
        pass


class ThisThesis(Sun):
    distance = 1.5e8 << u.m
    radius = 696e3 << u.km

class OtherThesis(Sun):
    distance = 1 << u.AU
    radius = 695e3 << u.km

When you use ThisThesis class, the log will be:

>>> pylog2pdf.LOG
{'Sun': 'ThisThesis'}

Of cource you can manually add anything you want to save:

>>> pylog2pdf["ThisParameter"] = 100 << u.K

Save the log to PDF file

Write the log to pdf file:

>>> pdf_path = "path/to/figure.pdf"
>>> fig.savefig(pdf_path)  # Create a pdf file first
>>> pylog2pdf.write_log(pdf_path)

Then you can read the log:

>>> pdf_path = "path/to/pdf/you/saved.pdf"
>>> pylog2pdf.read_log(pdf_path)
{'Sun': 'ThisThesis'}

This library is using Semantic Versioning.

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

pylog2pdf-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pylog2pdf-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file pylog2pdf-0.1.0.tar.gz.

File metadata

  • Download URL: pylog2pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for pylog2pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c26e87b1f2efd6a14c30138ca157a79ea4c113bd6b003a17008c917ed4e32e0e
MD5 0cf4e0c83384be404ccb0087d28c2b4a
BLAKE2b-256 168869a11d4ef55f9c1f73680ae23116024d082dbe417cede5fe62e3e6ddbf28

See more details on using hashes here.

File details

Details for the file pylog2pdf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylog2pdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for pylog2pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a67a9698ed1328a8d383b6d1cbe531a89723792e38bae0e8b8398563134a7a0f
MD5 854f730dec1da59f71fd16d55efb6edf
BLAKE2b-256 25e15dfa51cf8c5580f670c3c3855dea4dbe807200833c2350559078c1f35ee4

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