整合现有的第三方配方,用于对集和多集/袋进行分区。

PartitionSets的Python项目详细描述


分区集提供了一组由其他 多年的用户和麻省理工学院的许可。我稍微修改了一下 它们现在同样在Python2和Python3下工作。所有的虫子都是我的;-)

您可能会发现它对涉及小集合和多集合/包的任务很有用。

安装

一个简单的pip install PartitionSets就足够了。

用法

python代码中的典型用法如下:

#!/usr/bin/env python

from __future__ import print_function
from partitionsets import ordered_set
from partitionsets import partition

a_list = 'red green yellow blue'.split(" ")
an_oset = ordered_set.OrderedSet(a_list)
a_partition = partition.Partition(ordered_set)
for a_part in a_partition:
    print (a_part)

bin文件夹中的sriptpartition_sets.py可能提供有用的命令。 有关用法信息,请使用-hhelp选项运行它:

$> partition_sets.py -h
usage: partition_sets.py [-h] [-q | -v] [-o OUT_FILENAME] [-T {text,csv,json}]
                         [-b] [-m]
                         element [element ...]

partitioning of small sets with 25 or less members

positional arguments:
  element               define set as list of elements separated by spaces

optional arguments:
  -h, --help            show this help message and exit
  -q, --quiet
  -v, --verbosity       increase output verbosity
  -o OUT_FILENAME, --out-filename OUT_FILENAME
                        out file name if specified, else all sent to stdout
  -T {text,csv,json}, --type {text,csv,json}
                        type of output (format), defaults to text
  -b, --bell-numbers    export the Bell numbers known by package
  -m, --multi-set       handle elements as being par tof a multiset or bag

注释

请注意,此实现仅适用于具有25个成员或更少成员的集。

这种约束被认为是非常合理的,因为 整数索引)对于较大的数字开始溢出。记住:数字 每个附加构件的隔板都会急剧上升…

也要感谢

这个包仅仅包含了一些温和提供的菜谱(和评论) 在麻省理工学院的许可下通过几个人。我注意到的那些已经记在下面了。 任何遗漏的名字都是我的错。如果我接到通知,我会尽力 相应地更新、添加或删除下面列表中的项。

分区

  • 安东·弗雷德古尔
  • 克里斯·霍克

有序集

  • 唐·萨瓦茨基
  • 埃米尔墙
  • 雷蒙德·赫廷格

其他

有关进一步的参考,请参阅模块文件的注释。

参考文献

[a0001011]:“钟形或指数数:放置n个标记球的方法
http://oeis.org/A000110
[bell number]:维基百科条目bellu number
http://en.wikipedia.org/wiki/Bell_number
[oeis]:维基百科条目在线百科全书
http://en.wikipedia.org/wiki/On-Line_Encyclopedia_of_Integer_Sequences

[薄片8]:https://pypi.python.org/pypi/flake8

[ordsetimplpy]:http://code.activestate.com/recipes/576694/(与
来自don sawatzky评论的简化代码,这就足够了 对于此任务)

[部分复制]:http://code.activestate.com/recipes/577211/(r1)

[部分集合wp]:维基百科条目分区
http://en.wikipedia.org/wiki/Partition_of_a_set

[Pylint]:https://pypi.python.org/pypi/pylint

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
实现接口方法时不允许java@Override   使用BuffereImage加载映像时java高ram使用率   java For循环混乱,为什么不是循环?   java Android网格视图字符串对齐问题   java如何将方法与比较类型的附加功能进行比较?   在Java Swing中放置JSepator后的间隙大小   java如何避免并发访问我的网站中的支付链接   java如何从现有的Unix服务器连接到FTP服务器?   Spring中的java用户相关bean定义   带有scribesjava库的wordpress Woocommerce REST API返回消费者密钥参数缺失错误消息   java我可以自动检测特定设备连接的串行端口吗?   Javafx棋盘游戏   java使用JTextPane显示HTML,支持SVG吗?   SpringBoot如何在java中将映射转换为实体对象?   如何使用java代码对xls文件进行密码保护   Java JPA(EclipseLink)如何在持久化实际实体之前接收下一个生成的值?   Javaservlet启动外部进程