A mini implementation of python library.

Overview

minipy

author = RQDYSGN

date = 2021.10.11

version = 0.2

1. 简介

​ 基于python3.7环境,通过py原生库和leetcode上的一些习题构建的超小型py lib。

2. 环境

  • Python 3.7

2. 结构

${project_name}/
|-- __init__.py
|-- __pycache__
|   `-- __init__.cpython-37.pyc
|-- main.py
|-- minipy
|   |-- __init__.py
|   |-- __pycache__
|   |   |-- __init__.cpython-37.pyc
|   |   `-- math.cpython-37.pyc
|   |-- geometry
|   |   |-- Hypersphere.py
|   |   |-- Point.py
|   |   |-- __init__.py
|   |   `-- __pycache__
|   |       |-- Hypersphere.cpython-37.pyc
|   |       |-- Point.cpython-37.pyc
|   |       `-- __init__.cpython-37.pyc
|   |-- graph
|   |   |-- __init__.py
|   |   |-- __pycache__
|   |   |   |-- __init__.cpython-37.pyc
|   |   |   `-- graph.cpython-37.pyc
|   |   `-- graph.py
|   |-- list
|   |   |-- __init__.py
|   |   |-- __pycache__
|   |   |   |-- __init__.cpython-37.pyc
|   |   |   `-- numList.cpython-37.pyc
|   |   `-- numList.py
|   |-- math.py
|   `-- string
|       |-- SingleString.py
|       |-- __init__.py
|       `-- __pycache__
|           |-- SingleString.cpython-37.pyc
|           `-- __init__.cpython-37.pyc
|-- setup.py
`-- test_py
    |-- __init__.py
    |-- __pycache__
    |   |-- __init__.cpython-37.pyc
    |   |-- test_geometry.cpython-37-pytest-5.4.1.pyc
    |   |-- test_graph.cpython-37-pytest-5.4.1.pyc
    |   |-- test_list.cpython-37-pytest-5.4.1.pyc
    |   `-- test_string.cpython-37-pytest-5.4.1.pyc
    |-- test_geometry.py
    |-- test_graph.py
    |-- test_list.py
    `-- test_string.py

3. 测试

需提前安装pytest。基于pytest的简单测试,操作步骤:

cd leetcode/
py.test test_py/

Out:

image-20211009202706499

4. 安装&卸载

install:

cd leetcode/
pip install dist/minipy-0.1.tar.gz

uninstall:

pip uninstall minipy

5. 使用

An simple example:

import minipy as py

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    adj = [
        [0, 2, 6, 4],
        [float("inf"), 0, 3, float("inf")],
        [7, float("inf"), 0, 1],
        [5, float("inf"), 12, 0]
    ]
    g = py.graph(adj)
    g.print_adjacency()
    gg = py.shortestPathClass(g)
    print(gg.shortestPath(1, 0))
    print(gg.shortestCost(1, 0))
    print()

    numList1 = py.numList([])
    numList2 = py.numList([1, 1, 1, 1, 1])
    numList3 = py.numList([1, 2, 3, 4, 5])
    numList4 = py.numList([5, 1, 3, 2, 4])
    print(numList1.findMiddleIndex())
    print(numList1.minimumDifference(2))
    print(numList1.insertionSort())
    print(numList1.mergeSort())
    print(numList2.findMiddleIndex())
    print(numList2.minimumDifference(2))
    print(numList2.insertionSort())
    print(numList2.mergeSort())
    print(numList3.findMiddleIndex())
    print(numList3.minimumDifference(2))
    print(numList3.insertionSort())
    print(numList3.mergeSort())
    print(numList4.findMiddleIndex())
    print(numList4.minimumDifference(2))
    print(numList4.insertionSort())
    print(numList4.mergeSort())
    print()

    s = ""
    ss = py.SingleString(s)
    print('max power is', ss.maxPower())
    print()

    point1 = tuple([1, 2])
    point2 = tuple([-2, -2])
    p1 = py.Point2D(point1)
    p2 = py.Point2D(point2)
    print("p1 coordinate is", p1.coordinate)
    print("p2 coordinate is", p2.coordinate)
    print("Distance between p1 and p2 is", py.distance(p1, p2))

Out:

Graph:
0	2	6	4	
∞	0	3	∞	
7	∞	0	1	
5	∞	12	0	
[1, 2, 3, 0]
9

-1
-1
[]
[]
2
0
[1, 1, 1, 1, 1]
[1, 1, 1, 1, 1]
-1
1
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
2
1
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]

max power is 0

p1 coordinate is (1, 2)
p2 coordinate is (-2, -2)
Distance between p1 and p2 is 5.0
You might also like...
Rust syntax and lexical analyzer implemented in Python.
Rust syntax and lexical analyzer implemented in Python.

Rust Scanner Rust syntax and lexical analyzer implemented in Python. This project was made for the Programming Languages class at ESPOL (SOFG1009). Me

Core Python libraries ported to MicroPython

This is a repository of libraries designed to be useful for writing MicroPython applications.

A mini library for Policy Gradients with Parameter-based Exploration, with reference implementation of the ClipUp optimizer  from NNAISENSE.
A mini library for Policy Gradients with Parameter-based Exploration, with reference implementation of the ClipUp optimizer from NNAISENSE.

PGPElib A mini library for Policy Gradients with Parameter-based Exploration [1] and friends. This library serves as a clean re-implementation of the

This is the official implementation of TrivialAugment and a mini-library for the application of multiple image augmentation strategies including RandAugment and TrivialAugment.

Trivial Augment This is the official implementation of TrivialAugment (https://arxiv.org/abs/2103.10158), as was used for the paper. TrivialAugment is

Mini-hmc-jax - A simple implementation of Hamiltonian Monte Carlo in JAX

mini-hmc-jax This is a simple implementation of Hamiltonian Monte Carlo in JAX t

A collection of simple python mini projects to enhance your python skills

A collection of simple python mini projects to enhance your python skills

The ormar package is an async mini ORM for Python, with support for Postgres, MySQL, and SQLite.

python async mini orm with fastapi in mind and pydantic validation

Robocop is your personal mini voice assistant  made using Python.
Robocop is your personal mini voice assistant made using Python.

Robocop-VoiceAssistant To use this project, you should have python installed in your system. If you don't have python installed, install it beforehand

This mini project showcase how to build and debug Apache Spark application using Python
This mini project showcase how to build and debug Apache Spark application using Python

Spark app can't be debugged using normal procedure. This mini project showcase how to build and debug Apache Spark application using Python programming language. There are also options to run Spark application on Spark container

Projeto de mini-games de azar com interface gráfica utilizando Python e PySimpleGui.
Projeto de mini-games de azar com interface gráfica utilizando Python e PySimpleGui.

Gambling Mini jogos de azar unidos em uma mesma interface gráfica, utilizando a linguagem de programação Python em conjunto com a biblioteca de interf

Python Interactive Mini Games
Python Interactive Mini Games

Python Interactive Mini Games Mini projects from Coursera's An Introduction to I

Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code.
Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code.

Mini Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code. The code is written and published as is, so the

DBMS Mini-project: Recruitment Management System
DBMS Mini-project: Recruitment Management System

# Hire-ME DBMS Mini-project: Recruitment Management System. 💫 ✨ Features Python + MYSQL using mysql.connector library Recruiter and Client Panel Beau

An open-source, mini imitation of GitHub Copilot for Emacs.
An open-source, mini imitation of GitHub Copilot for Emacs.

Second Mate An open-source, mini imitation of GitHub Copilot using EleutherAI GPT-Neo-2.7B (via Huggingface Model Hub) for Emacs. This is a much small

Vanilla and Prototypical Networks with Random Weights for image classification on Omniglot and mini-ImageNet. Made with Python3.

vanilla-rw-protonets-project Vanilla Prototypical Networks and PNs with Random Weights for image classification on Omniglot and mini-ImageNet. Made wi

A mini lib that implements several useful functions binding to PyTorch in C++.

Torch-gather A mini library that implements several useful functions binding to PyTorch in C++. What does gather do? Why do we need it? When dealing w

Mini-calculadora escrita como exemplo para uma palestra relâmpago sobre `git bisect`

Calculadora Mini-calculadora criada para uma palestra relâmpado sobre git bisect. Tem até uma colinha! Exemplo de uso Modo interativo $ python -m calc

Mini Tool to lovers of debe from eksisozluk (one of the most famous website -reffered as collaborative dictionary like reddit- in Turkey) for pushing debe (Most Liked Entries of Yesterday) to kindle every day via Github Actions.

debe to kindle Mini Tool to lovers of debe from eksisozluk (one of the most famous website -refered as collaborative dictionary like reddit- in Turkey

A new mini-batch framework for optimal transport in deep generative models, deep domain adaptation, approximate Bayesian computation, color transfer, and gradient flow.

BoMb-OT Python3 implementation of the papers On Transportation of Mini-batches: A Hierarchical Approach and Improving Mini-batch Optimal Transport via

Owner
RQDYGSN
RQDYGSN
DO NOT USE. Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.

IronPython 3 IronPython3 is NOT ready for use yet. There is still much that needs to be done to support Python 3.x. We are working on it, albeit slowl

IronLanguages 2k Dec 30, 2022
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

The MicroPython project This is the MicroPython project, which aims to put an implementation of Python 3.x on microcontrollers and small embedded syst

MicroPython 15.7k Dec 31, 2022
A faster and highly-compatible implementation of the Python programming language. The code here is out of date, please follow our blog

Pyston is a faster and highly-compatible implementation of the Python programming language. Version 2 is currently closed source, but you can find the

null 4.9k Dec 21, 2022
A faster and highly-compatible implementation of the Python programming language.

Pyston Pyston is a fork of CPython 3.8.8 with additional optimizations for performance. It is targeted at large real-world applications such as web se

null 2.3k Jan 9, 2023
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.

pythonnet - Python.NET Python.NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) a

null 3.5k Jan 6, 2023
The Python programming language

This is Python version 3.10.0 alpha 5 Copyright (c) 2001-2021 Python Software Foundation. All rights reserved. See the end of this file for further co

Python 49.7k Dec 30, 2022
Grumpy is a Python to Go source code transcompiler and runtime.

Grumpy: Go running Python Overview Grumpy is a Python to Go source code transcompiler and runtime that is intended to be a near drop-in replacement fo

Google 10.6k Dec 24, 2022
x86-64 assembler embedded in Python

Portable Efficient Assembly Code-generator in Higher-level Python (PeachPy) PeachPy is a Python framework for writing high-performance assembly kernel

Marat Dukhan 1.7k Jan 3, 2023
Pyjion - A JIT for Python based upon CoreCLR

Pyjion Designing a JIT API for CPython A note on development Development has moved to https://github.com/tonybaloney/Pyjion FAQ What are the goals of

Microsoft 1.6k Dec 30, 2022
The Stackless Python programming language

This is Python version 3.7.0 alpha 4+ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 20

Stackless Python 891 Jan 3, 2023