Comparable
==========
[![Build Status](http://img.shields.io/travis/jacebrowning/comparable/master.svg)](https://travis-ci.org/jacebrowning/comparable)
[![Coverage Status](http://img.shields.io/coveralls/jacebrowning/comparable/master.svg)](https://coveralls.io/r/jacebrowning/comparable)
[![PyPI Version](http://img.shields.io/pypi/v/Comparable.svg)](https://pypi.python.org/pypi/Comparable)
[![PyPI Downloads](http://img.shields.io/pypi/dm/Comparable.svg)](https://pypi.python.org/pypi/Comparable)
Comparable is a library providing abstract base classes that enable subclasses to be compared for "equality" and "similarity" based on their attributes.
Getting Started
===============
Requirements
------------
* Python 3.3+
Installation
------------
Comparable can be installed with 'pip':
pip install Comparable
Or directly from the source code:
git clone https://github.com/jacebrowning/comparable.git
cd comparable
python setup.py install
Basic Usage
===========
After installation, abstract base classes can be imported from the package:
python
>>> import comparable
comparable.__version__
>>> from comparable import SimpleComparable, CompoundComparable
Comparable classes use `==` as the operation for "equality" and `%` as the operation for "similarity". They may also override a `threshold` attribute to set the "similarity" ratio.
Simple Comparables
------------------
Simple comparable types must override the `equality` and `similarity` methods to return bool and Similarity objects, respectively. See `comparable.simple` for examples.
Compound Comparables
--------------------
Compound comparable types contain multiple simple comparable types. They must override the `attributes` property to define which attributes should be used for comparison. See `comparable.compund` for examples.
Examples
========
Comparable includes many generic comparable types:
python
>>> from comparable.simple import Number, Text, TextEnum, TextTitle
>>> from comparable.compound import Group
A basic script may look similar to the following:
from comparable.simple import TextTitle
from comparable import tools
base = TextTitle("The Cat and the Hat")
items = [TextTitle("cat & hat"), TextTitle("cat & the hat")]
print("Equality: {}".format(base == items[0]))
print("Similarity: {}".format(base % items[0]))
print("Duplicates: {}".format(tools.duplicates(base, items)))
For Contributors
================
Requirements
------------
* GNU Make:
* Windows: http://cygwin.com/install.html
* Mac: https://developer.apple.com/xcode
* Linux: http://www.gnu.org/software/make (likely already installed)
* virtualenv: https://pypi.python.org/pypi/virtualenv#installation
* Pandoc: http://johnmacfarlane.net/pandoc/installing.html
* Graphviz: http://www.graphviz.org/Download.php
Installation
------------
Create a virtualenv:
make env
Run the tests:
make test
make tests # includes integration tests
Build the documentation:
make doc
Run static analysis:
make pep8
make pep257
make pylint
make check # includes all checks
Prepare a release:
make dist # dry run
make upload
PyPI 官网下载 | Comparable-0.2.tar.gz
版权申诉
151 浏览量
2022-02-10
06:13:15
上传
评论
收藏 15KB GZ 举报
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
最新资源
- 基于STM32驱动MLX90614红外测温模块和OLED屏幕,测温的同时如果超过37度会在屏幕上显示报警信息
- Stability.postman-collection.json
- SQL 语言入门篇-最常用 SQL 语句大全
- mysql查询语句汇总.zip
- typora-x64-v0.9.93,windows,64位,markdown工具,文本编辑器
- 基于C语言的neon_osd_Draw ARM Neon加速OSD点阵设计源码
- 目标检测-工地工人安全设备佩戴检测数据集-3500张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本+训练日志
- 运筹学运输问题综合实验的实验报告
- home - 副本.vue
- imageProcess.py
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈