Skip to main content

A python library for degree calculations and conversions.

Project description

degrees V0.3.0.post1

Note:

This is the only version that is stable and compatible with python 3.8.

The older versions are NOT stable.

Contents

  • Introduction
  • Importing
  • Class
    • Degree
  • Functions
    • degree2radian
    • radian2degree
    • normalize
  • Changelog

Introduction

A python library for degree calculations and conversions.

Added in version 0.2: Supported pickle.

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 math.trunc(a)
    abs(a) math.ceil(a) math.floor(a) a % b
    a // b +a -a hash(a)

    Added in version 0.1.7: Implemented the math.trunc function on the Degree objects.

  • conversions:

    int(a) float(a) str(a) repr(a) bool(a) complex(a)

    The complex(degree_obj) is different from degree_obj.to_complex(length). The former returns int(degree_obj)+0j, but the latter returns complex(length * cos(theta), length * sin(theta)), theta=degree2radian(degree_obj).

For example:

import degrees
a = degrees.Degree(45)
print(complex(a))  # (45+0j)
print(a.to_complex(2 ** 0.5))  # about (1+1j)
  • comparisons:

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

    Return a degree object from a string. The dms characters should be °, ' and ".

  • staticmethod from_unicode(string)

    Similar to from_str, but the dms characters should be °, and .

    Added in version 0.1.10.

  • staticmethod from_iter(iterable)

    Return a degree object from an iterable.

  • 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.

  • to_complex(length: Union[int, float])

    Returns the complex number corresponding to (angle=self, radius=length).

    Added in version 0.2.1.

  • 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.

Version

version_info

Consts

DEGREE
MINUTE
SECOND

Equals to °, and .

Changelog

  1. Nothing.

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.3.0.post1.tar.gz (8.9 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.3.0.post1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file degrees-0.3.0.post1.tar.gz.

File metadata

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

File hashes

Hashes for degrees-0.3.0.post1.tar.gz
Algorithm Hash digest
SHA256 448deec79a4af22cfa9eff089efbfd2edd3abdda8a29918ed3ffefbf1ae74e26
MD5 c580505be7e419342ac9e4de8ad7b676
BLAKE2b-256 046dbb324aa0ff66e198580e5b63c689b2e3478fd437bc46818b26d2b62d609e

See more details on using hashes here.

File details

Details for the file degrees-0.3.0.post1-py3-none-any.whl.

File metadata

  • Download URL: degrees-0.3.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 8.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.3.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e3acf304735f4e4a19bdea8e42cb8a823e00f5256ccd0b5ac81c763cb7f809b
MD5 09d0703449d1c73f381fc5d1f5e778e8
BLAKE2b-256 50ba75360807d7a2d8c073e391fbdaa6811f1b6531b8120c8dd4159fc363af5a

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