Skip to main content

A package for manipulating latin squares

Project description

Latin Squares

This is a small package for generating and manipulating Latin Squares. It was created to support games an other applications for the Callysto Project. It hasn't been particularly widely tested or optimized so use at your own risk.

Getting Started

This package implements a LatinSquare object with various methods to initialize, generate new squares, check validity and things like that.

>>> import numpy as np
>>> # from src.latinsq import LatinSquare
>>> from latinsq import LatinSquare


>>> # Initialize from values
>>> square = np.array([
[1, 2, 3],
[3, 1, 2],
[2, 3, 1]
])
>>> ls = LatinSquare(square)
array([[1, 2, 3],
       [3, 1, 2],
       [2, 3, 1]])

>>> square.valid()
True

>>> # Generate a random square
>>> LatinSquare.random(n=3)
array([[2, 1, 3],
       [3, 2, 1],
       [1, 3, 2]])

The random generator attempts to implement an algorithm described by Jacobson and Matthews draw a random latin square uniformly from the space of valid latin squares.

References

  1. Wikipedia article: Latin Squares
  2. Generating Uniformly distributed random latin squares - Jacobson & Matthews doi:10.1002/(sici)1520-6610(1996)4:6<405::aid-jcd3>3.0.co;2-j
  3. susansmathgames.ca has an article on latin and euler squares with good exposition on teaching with squares.
  4. Knuth, The Art of Computer Programming Volume 4A supposedly has a discussion. I haven't seen it yet, but will probably be interesting.
  5. Wolfram.com latin squares.
  6. Enclopedia of Mathematics.
  7. Blog article with go implementation. This is probably closest to the version implemented here.
  8. SageMath Latin Square Implementation - A recent find, but if we can split out the dependencies might be very useful.

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

latinsq-0.2.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

latinsq-0.2.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file latinsq-0.2.3.tar.gz.

File metadata

  • Download URL: latinsq-0.2.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for latinsq-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ad1fd5092ede576a96217a306afaa95997af945957a7904d7ff9fd438b8f922c
MD5 07ad88c2cd5141123b03cd8059c6a0de
BLAKE2b-256 9300c2d831b2a915cc1608d09a1ffcbea4dc06981a63c7ddf4b01ac0a3bf091a

See more details on using hashes here.

File details

Details for the file latinsq-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: latinsq-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for latinsq-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ee5df40880c7bb5a5c35dfb4471790091f20e14f4ea7575648483425166c60c
MD5 66e5f2a0ea3ce2f3b3833ed5a94385ae
BLAKE2b-256 5eb3b4172ba75d2942e137f83abcb50cadc4b299a733d7c49444d82d976b3eb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page