Skip to content

Commit

Permalink
fix bug with celestial equator (#96)
Browse files Browse the repository at this point in the history
* fix

* better

* multiprocessing hash checks
  • Loading branch information
steveberardi authored Aug 31, 2024
1 parent 98fdaf6 commit 6ef2089
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
- Fixes default horizon style to be consistent with grayscale extension
- [**v0.11.2**]
- Adds `requests` as a required dependency
- [**v0.11.3**]
- Fixes bug with plotting the celestial equator

## v0.10.x
[Documentation](https://archives.starplot.dev/0.10.2/)
Expand Down
32 changes: 18 additions & 14 deletions hash_checks/hashio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import time

from multiprocessing import Pool
from pathlib import Path

import imagehash
Expand Down Expand Up @@ -73,22 +74,25 @@ def _dhash(self, img) -> str:
def _phash(self, img) -> str:
return str(imagehash.phash(img))

def _call_wrapper(self, c):
func_name = c.__name__[6:]
console.print(f"{func_name}...")
filename = c()
img = Image.open(filename)
return func_name, {
"filename": str(filename),
"dhash": self._dhash(img),
"phash": self._phash(img),
}

def _get_hashes(self) -> dict:
"""Gets hashes for all callables"""
hashes = {}
with console.status("Getting hashes...", spinner="aesthetic"):
for c in self.callables:
func_name = c.__name__[6:]
console.print(f"{func_name}...")
filename = c()
img = Image.open(filename)
hashes[func_name] = {
"filename": str(filename),
"dhash": self._dhash(img),
"phash": self._phash(img),
}

return hashes

console.print("Getting hashes...", style="bold")
with Pool(5) as p:
results = p.map(self._call_wrapper, self.callables)

return {func_name: hashes for func_name, hashes in results}

def _check(self):
passed = {}
Expand Down
2 changes: 1 addition & 1 deletion src/starplot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Star charts and maps"""

__version__ = "0.11.2"
__version__ = "0.11.3"

from .base import BasePlot # noqa: F401
from .map import MapPlot, Projection # noqa: F401
Expand Down
7 changes: 2 additions & 5 deletions src/starplot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,8 @@ def celestial_equator(

# TODO : handle wrapping

ra_start = max(0, int(self.ra_min) - 2) * 100
ra_end = min(24, int(self.ra_max) + 2) * 100

for ra in range(ra_start, ra_end, 2):
x0, y0 = self._prepare_coords(ra / 100, 0)
for ra in range(25):
x0, y0 = self._prepare_coords(ra, 0)
x.append(x0)
y.append(y0)

Expand Down

0 comments on commit 6ef2089

Please sign in to comment.