Skip to content

Commit 2cf0e77

Browse files
Merge pull request #40 from spectriclabs/sha256
Replaced md5 with sha256
2 parents 92bff67 + c4ae31a commit 2cf0e77

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

elastic_datashader/drawing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import lru_cache
2-
from hashlib import md5
2+
from hashlib import sha256
33
from typing import Dict, Iterable, Tuple
44

55
import io
@@ -23,7 +23,7 @@ def get_categorical_color_index(category: str, num_colors: int) -> int:
2323
across independent tile generations, but can result in situations where
2424
colors are reused before exhausting the color palette.
2525
"""
26-
category_hash = md5(bytes(category, encoding="utf-8")).hexdigest()
26+
category_hash = sha256(bytes(category, encoding="utf-8")).hexdigest()
2727
number = int(category_hash[0:2], 16)
2828
return number % num_colors
2929

elastic_datashader/parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime, timedelta, timezone
2-
from hashlib import md5
2+
from hashlib import sha256
33
from json import loads
44
from socket import gethostname
55
from time import sleep
@@ -244,7 +244,7 @@ def get_time_bounds(now: datetime, from_time: Optional[str], to_time: Optional[s
244244

245245
def get_parameter_hash(params: Dict[str, Any]) -> str:
246246
"""Calculates a hash value for the specific parameter set"""
247-
parameter_hash = md5()
247+
parameter_hash = sha256()
248248

249249
for _, p in sorted(params.items()):
250250
if isinstance(p, datetime):

elastic_datashader/tilegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def all_ellipse_fields_have_values(locs, majors, minors, angles, field_names: El
118118

119119
def normalize_ellipses_to_list(locs, majors, minors, angles):
120120
'''
121-
If its a list determine if there are multiple ellipses or just a single ellipse in list format
121+
If it's a list determine if there are multiple ellipses or just a single ellipse in list format
122122
'''
123123
if isinstance(locs, (AttrList, list)):
124124
if (

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ Pillow = "*"
3232
pynumeral = "*"
3333
arrow = "*"
3434
python-datemath = "*"
35-
numba = "*"
35+
numba = "0.56.4"
3636
numpy = "^1.23"
3737
PyYAML = "*"
3838
humanize = "*"
3939
uvicorn = {extras = ["standard"], version = "^0.18.2", optional = true}
4040
fastapi = "^0.86"
41-
georgio = "2022.313.1239"
41+
georgio = "2022.335.152"
4242

4343
[tool.poetry.dev-dependencies]
4444
pytest = "*"

tests/test_drawing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
(
1414
("foo", "bar", "baz", "Other", "N/A"),
1515
{
16-
"bar": "#8a9500",
17-
"baz": "#870062",
18-
"foo": "#9a0390",
16+
"bar": "#b5e2e1",
17+
"baz": "#672138",
18+
"foo": "#bfebc3",
1919
"Other": "#AAAAAA",
2020
"N/A": "#666666",
2121
}
@@ -84,7 +84,7 @@ def test_ellipse_planar_points():
8484
np.testing.assert_almost_equal(actual_x[8], 0)
8585
np.testing.assert_almost_equal(actual_x[12], -50)
8686

87-
87+
8888

8989
radm = 100
9090
radn = 30

tests/test_parameters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def test_get_category_field():
119119
assert parameters.get_category_field("banana") == "banana"
120120

121121
def test_get_parameter_hash():
122-
assert parameters.get_parameter_hash({"foo": "bar", "baz": 1}) == "0d922e38f1a94fdc8acc6016c333d49e"
123-
assert parameters.get_parameter_hash({"foo": "bar", "baz": 1, "abc": datetime(2022, 2, 17, 11, 0, 0, tzinfo=timezone.utc)}) == "5463c0e1ae7f3c9e182afc2786050765"
124-
assert parameters.get_parameter_hash({}) == "d41d8cd98f00b204e9800998ecf8427e"
122+
assert parameters.get_parameter_hash({"foo": "bar", "baz": 1}) == "a6488297eb1cdaa23e196800b1c399b13d9a5c86cfecaf8f9fd0fbe9af7533db"
123+
assert parameters.get_parameter_hash({"foo": "bar", "baz": 1, "abc": datetime(2022, 2, 17, 11, 0, 0, tzinfo=timezone.utc)}) == "88ade56886a8099e6fd3c25525a0fb9ab3938be64374569480ed3bfd7f3d70e9"
124+
assert parameters.get_parameter_hash({}) == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
125125

126126
def test_get_time_bounds_already_quantized():
127127
now = datetime(2022, 6, 14, 12, 15, 0, tzinfo=timezone.utc)

0 commit comments

Comments
 (0)