Skip to main content

Extended sets

Project description

eset

Extended sets - support for set complement

Overview

An eset works like a normal python set except that you can invert it to generate its complement. For example, let's say you have the following:

>>> from esets import eset
>>> s = eset(['hello', 'there'])
>>> s_invert = ~s
>>> s_invert
~eset(['hello', 'there'])

In this example, s_invert contains everything except 'hello' and 'there'.

Logic

All the logic operations you'd expect from sets are available in esets, including intersection, union, difference, and symmetric difference. Use the &, |, -, and ^ operators respectively.

Similarly, conditional expressions are available to determine subset relationships. If A <= B, that A is a subset of B.

Infinities

You'll note there's an inf.py module that implement א‎0 and א‎1 infinities, that is, countable and uncountable infinities. This was implemented so that cardinality calculations would be correct for complement sets: discussed below.

>>> from esets import inf
>>> inf.countable, inf.uncountable
(א‎0, א‎1)
>>> inf.countable < inf.uncountable
True

Cardinality

The abs expression (also cardinality method) will return a countably infinite scalar if in complement mode; otherwise it returns the count of items in set.

>>> from esets import eset, inf
>>> s = eset(['hello', 'there'])
>>> abs(s)
2
>>> abs(~s)
א‎0

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

esets-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file esets-0.2.0.tar.gz.

File metadata

  • Download URL: esets-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for esets-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d278f0fbe2fb791444b8a3b47248412e81762b17fca80ecc23eb6f16f81b3b3c
MD5 c0646149a7ce2bfbb62e4969a9f54a3d
BLAKE2b-256 06bc55281ed5c2e3a6b80b5b5ccb373693a3ab2445d6918ec21538199575464e

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