Giter VIP home page Giter VIP logo

pylog2pdf's Introduction

PyLog2PDF

PyPI Python Test License

PDF, a visualisation of your calculation, can store 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.LOG["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.

pylog2pdf's People

Contributors

kaorunishikawa avatar dependabot[bot] avatar

Watchers

 avatar

pylog2pdf's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.