Skip to main content

A python lib for degree calculations and conversions

Project description

degrees V0.1.6

Contents

  • Introduction
  • Importing
  • Class
    • Degree
  • Functions
    • degree2radius
    • radius2degree
    • convert_to_360
  • Changelog

Introduction

A python lib for degree calculations and conversions

Importing

Just type import degrees.

Class

  • class degrees.Degree(number)
    class degrees.Degree(degree_obj)
    class degrees.Degree(degree=0, minute=0, second=0)

    • Creating a Degree object

import degrees

print(degrees.Degree(1))  # 1°
print(degrees.Degree(2, 3, 4))  # 2°3'4"
print(degrees.Degree(1, second=2))  # 1°0'2"
print(degrees.Degree(1, 3))  # 1°3'
print(degrees.Degree(0, -1))  # -1'
print(degrees.Degree(1.5))  # 1°30'
print(degrees.Degree(2, -4))  # ValueError: if degree is not 0, minute and second must be positive integer
  • calculating:

    a + b a - b a * b a / b
    abs(a) math.ceil(a) math.floor(a) a % b
    a // b +a -a hash(a)
  • conversions:

    int(a) float(a) str(a) repr(a) bool(a)
  • comparisons:

    a >= b a > b a = b
    a <= b a < b a != b
  • staticmethod from_str(string)

    Return a degree object from a string.

  • staticmethod from_iter(iterable)

    Return a degree object from an iterable.

  • functools.cached_property total_seconds

    The total seconds of a degree object.

  • deg

    The degree of a degree object(without sign).

  • min

    The minute of a degree object(without sign).

  • sec

    The second of a degree object(without sign).

  • sign

    The sign of a degree object.

  • property dms

    A tuple of (degree, minute, second).

Note

The attributes of Degree are read-only.

Functions

def degree2radian(x: Degree, /)

  • Convert angle x from a degree object to radians.

def radian2degree(x: Union[int, float], /)

  • Convert angle x from radians to a degree object.

def normalize(x: Degree, /)

  • Be using for angle normalization.

Note:

These functions are renamed since version 0.1.5(did NOT declared in the doc of V0.1.5).

Version

version_info

Changelog

  1. Updated README.md(did NOT change the source code).

Write in the end

If you found the bug in the code, you can email me at snake830@vip.163.com. I am happy to receive the advice!

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

degrees-0.1.6.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

degrees-0.1.6-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file degrees-0.1.6.tar.gz.

File metadata

  • Download URL: degrees-0.1.6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for degrees-0.1.6.tar.gz
Algorithm Hash digest
SHA256 53f35cb52ef6a161f89886000db30073e634c23f730b3de3ad0af376d5a10528
MD5 8c056edc1d5e52a0f73b230ad69d4a3d
BLAKE2b-256 f2a69ba5254183cd0b285ff489e67012d59d28b17362f298836f3c1ef4fcab3a

See more details on using hashes here.

File details

Details for the file degrees-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: degrees-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for degrees-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a59c8095eff971faac37fde52b14a2c93c06af13e1e7eb20ee2a3fae0a2667
MD5 3e82871d2c86c07e7667b497cbdc1661
BLAKE2b-256 505be5f79b090eab29bcad242d8dd75e5c7ea9da2e16afe3a9c03dd9a3609bc2

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