Skip to main content

Symmetria provides an intuitive, thorough, and comprehensive framework for interacting with the symmetric group and its elements.

Project description

Welcome to symmetria

Symmetria provides an intuitive, thorough, and comprehensive framework for interacting with the symmetric group and its elements.

  • 📦 - installable via pip
  • 🐍 - compatible with Python 3.9, 3.10, 3.11 and 3.12
  • 👍 - intuitive API
  • 🧮 - a lot of functionalities already implemented
  • ✅ - 100% of test coverage

You can give a look at how to work with symmetria in the section quickstart, or you can directly visit the docs.

An interesting list of all the functionalities implemented by symmetria can be found here.

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change, and give a look to the contribution guidelines.

Installation

Symmetria can be comfortably installed from PyPI using the command

pip install symmetria

or directly from the source GitHub code with

pip install git+https://github.com/VascoSch92/symmetria@xxx

where xxx is the name of the branch or the tag you would like to install.

You can check that symmetria was successfully installed by typing the command

symmetria --version

Quickstart

Let's get started with symmetria. First and foremost, we can import the Permutation class from symmetria. The Permutation class serves as the fundamental class for working with elements of the symmetric group, representing permutations as bijective maps. Additionally, you can utilize the Cycle class and CycleDecomposition class to work with cycle permutations and permutations represented as cycle decompositions, respectively.

from symmetria import Permutation

permutation = Permutation(1, 3, 4, 5, 2, 6)

You can now represent your permutation in various formats:

print(permutation)                      # (1, 3, 4, 5, 2, 6)
print(permutation.cycle_notation())     # (1)(2 3 4 5)(6)
print(permutation.one_line_notation()   # 134526

Permutations can be compared between them and are easy to manipulate.

if permutation:
    print("The permutation is different from the identity.")
if permutation == Permutation(1, 2, 3, 4, 5, 6):
    print("The permutation is equal to the identity.")
if len(permutation) == 6:
    print("The permutation acts on 6 elements.")
print(permutation * permutation)

Furthermore, we can decompose a permutation into its cycle decomposition (CycleDecomposition) and compute its order and support.

permuttation.cycle_decomposition()
# returns CycleDecomposition(Cycle(1), Cycle(2, 3, 4, 5), Cycle(6))
permutation.order()  # 4
permutation.support()  # {2, 3, 4, 5}
permutation.is_derangement()  # True

Overview

Overview
Open Source MIT
CI/CD tests Documentation Status
Code !pypi !python-versions !black
Downloads Downloads Downloads Downloads

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

symmetria-0.0.2.tar.gz (20.9 kB view hashes)

Uploaded Source

Built Distribution

symmetria-0.0.2-py3-none-any.whl (22.2 kB view hashes)

Uploaded Python 3

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