Skip to main content

A python lib for degree calculations and conversions

Project description

degrees V0.1.1a1

Contents

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

      >>> degrees.Degree(1)
      1°
      >>> degrees.Degree(2, 3, 4)
      2°3'4"
      >>> degrees.Degree(1, second=2)
      1°0'2"
      >>> degrees.Degree(1, 3)
      1°3'
      >>> degrees.Degree(0, -1)
      -1'
      >>> degrees.Degree(2, -4)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
          degrees.Degree(2, -4)
          ~~~~~~^^^^^^
        File "/degrees.py", line 32, in __init__
          raise ValueError("if degree is not 0, minute and second must be positive integer")
      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)1
    • 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.

Note

  1. The attributes of Degree are read-only.

Functions

def degree2radius(x: Degree, /)

  • Convert angle x from a degree object to radians.

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

  • Convert angle x from radians to a degree object.

def convert_to_360(x: Degree, /)

  • Be using for angle normalization.

Changelog

  1. Simplified class _Type(for type annotation), you can use it on Python 3.7+(in the previous version, it only supports Python 3.12+).
  2. Rewrite the method Degree.__hash__. Now it can execute perfectly.
  3. Added methods: Degree.from_string, Degree.from_iter, property Degree.total_seconds.
  4. Added Degree.deg, Degree.min and Degree.sec in the document.
  5. Will yank Degree 0.1.0 after the final version release.

Write in the end

If you found the bug in the code, you can email me at snake830@vip.163.com. I'm 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.1a1.tar.gz (7.6 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.1a1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file degrees-0.1.1a1.tar.gz.

File metadata

  • Download URL: degrees-0.1.1a1.tar.gz
  • Upload date:
  • Size: 7.6 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.1a1.tar.gz
Algorithm Hash digest
SHA256 53641e4dd0d9237ac6b36261d6adffcedd701549fdb9ad5bcccc477203dbd2ab
MD5 ffbd9021a59a775d23c9d71b09b0f6be
BLAKE2b-256 6ec53b278b467707b843300cec2785ca7c232904b7ebc4b1ebd0dcffdd172354

See more details on using hashes here.

File details

Details for the file degrees-0.1.1a1-py3-none-any.whl.

File metadata

  • Download URL: degrees-0.1.1a1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 b18ab658f326bb9d4e4699f070d18a1b11a08c6139c7de2e075327273954fbfa
MD5 d32b1f49de4c392736627010aa6e42ad
BLAKE2b-256 5f265e94b11dc5abee61b65028cb63f91a9e1e313a1fc816f00c3bb4287d6736

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