flatlib Documentation

repository·master·Indexed 18 days ago

https://github.com/flatangle/flatlib

A Python 3 library for Traditional Astrology used to calculate astrological charts based on specific dates, times, and geographic positions. It provides classes for Datetime, GeoPos, and Chart, allowing users to retrieve celestial bodies, houses, angles, and fixed stars. The library depends on the Swiss Ephemeris (via pyswisseph) and is released under the MIT License.

Tokens
4.3K
Snippets
24
Records
27
Agent score
59%

What's inside flatlib

  1. Work with Python lists and dictionaries

    master

    Python uses two primary data structures for organizing data:

    Lists

    A list is a zero-based sequence of variables. You access elements using their index number inside square brackets [].

    Dictionaries

    A dictionary is a collection of key-value pairs. Unlike lists, you access values using a key (such as a string) inside square brackets [] rather than a numeric index.

    # List example
    mylist = [-5, 0.3, 2.5, 33]
    print(mylist[1])  # Returns 0.3
    
    # Dictionary example
    mydict = {'name': 'John Doe', 'age': 32}
    print(mydict['name'])  # Returns 'John Doe'
  2. Understand flatlib licensing and commercial use

    master

    Flatlib is released under the MIT License, which allows for use in commercial projects. However, there is a critical dependency: flatlib uses the Swiss Ephemeris, which is licensed under GPL.

    If you intend to use flatlib in a commercial project, you must either:

    1. Adhere to the GPL license requirements.
    2. Purchase a commercial license for the Swiss Ephemeris.
  3. Quickstart with Flatlib

    master

    Flatlib is a Python 3 library designed for Traditional Astrology. You can create an astrological chart by defining a Datetime object for the time, a GeoPos object for the geographic coordinates, and passing them to the Chart constructor. Once a Chart is initialized, you can retrieve specific celestial bodies using chart.get() and constants from the const module.

    >>> date = Datetime('2015/03/13', '17:00', '+00:00')
    >>> pos = GeoPos('38n32', '8w54')
    >>> chart = Chart(date, pos)
    
    >>> sun = chart.get(const.SUN)
    >>> print(sun)
    <Sun Pisces +22:47:25 +00:59:51>
  4. Perform basic operations on numbers and strings

    master

    Python supports standard arithmetic operations on numeric types (integers and floats):

    • Addition: +
    • Subtraction: -
    • Multiplication: *
    • Division: /

    Some operations, like addition (+), can also be applied to strings to concatenate them. However, operations like subtraction (-) are not supported for strings and will raise a TypeError.

    >>> num1 = 10
    >>> num2 = 20
    >>> num1 + num2
    30
    
    >>> name1 = 'Homer'
    >>> name2 = 'Simpson'
    >>> name1 + name2
    'HomerSimpson'
  5. Run the documentation live-reload server

    master

    To preview documentation changes in real-time, use the make livehtml command from the docs directory. This starts a sphinx-autobuild server.

    1. Run make livehtml.
    2. Open your browser and visit http://localhost:8000.
    3. The page will automatically reload whenever you save changes to the source files.
    4. Press Ctrl+C (or Command+C) to stop the server.
    cd docs
    make livehtml
  6. Build the flatlib HTML documentation

    master
    You can build the static HTML version of the documentation using the provided Makefile. Navigate to the docs directory in your terminal and run make html. The output will be located in docs/build/html.
    cd docs
    make html
  7. Use variables and the print command in Python

    master

    Variables are used to store values in memory. You assign values to variables using the equal sign (=). You can use the print() function to display the contents of a variable or a string.

    Supported types include integers, floating point numbers, and strings (text enclosed in quotation marks).

    >>> number = 100
    >>> name = "John"
    >>> print(number)
    100
    >>> print(name)
    John
  8. Install flatlib on Windows

    master

    To install flatlib on Windows, ensure Python 3 is installed. You can verify the installation by running py in the command line. Install the package using pip via the Python launcher.

    Note on C Compilers: flatlib depends on pyswisseph (a Python port of the Swiss Ephemeris), which requires a C compiler to build. If you encounter the error Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat), you must install a C compiler such as Visual C++ 2010 Express.

    If using Visual C++ 2010, use the following commands to set the environment and install:

    set CL=-DWIN32
    py -m pip install flatlib