Skip to content

Commit

Permalink
cache cities data for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
hoishing committed Dec 9, 2024
1 parent 7c19c63 commit 59ac988
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions natal/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
import swisseph as swe
from datetime import datetime
from functools import cached_property
from math import floor
from natal.classes import Aspect, Aspectable, Body, Extra, House, Planet, Sign, Vertex
from natal.config import Config, DotDict
Expand Down Expand Up @@ -29,8 +30,6 @@ class Data(DotDict):
Data object for a natal chart.
"""

cities = pd.read_csv(data_folder / "cities.csv.gz")

def __init__(
self,
name: str,
Expand Down Expand Up @@ -306,3 +305,7 @@ def composite_aspects_pairs(self, data2: Self) -> BodyPairs:
BodyPairs: Pairs of bodies to check for aspects
"""
return itertools.product(self.aspectables, data2.aspectables)

@cached_property
def cities(self) -> pd.DataFrame:
return pd.read_csv(data_folder / "cities.csv.gz")
Binary file modified natal/data/cities.csv.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "natal"
version = "0.8.6"
version = "0.8.7"
description = "create Natal Chart with ease"
license = "MIT"
repository = "https://github.com/hoishing/natal"
Expand Down

0 comments on commit 59ac988

Please sign in to comment.