Skip to content

Commit

Permalink
Use md5 hashing, faster than SHA1
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Jun 21, 2022
1 parent 6787d40 commit 611a1bf
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 105 deletions.
88 changes: 44 additions & 44 deletions tests/papers/RHS2007.json
@@ -1,90 +1,90 @@
{
"WE_thick": {
"img": "f74e52cbe48c5d1ecc166db61e4df0d3fc99b2e1",
"mask": "9fb2884af6bfc2b675ffdfa7fe2efc96f8915c04"
"img": "4e6d0130b6f37eeaff7f568c31c68325",
"mask": "b523788d266b5f7ded635717acad5a54"
},
"WE_thin_wide": {
"img": "c5581022313dea052d952be1e05cb84839680166",
"mask": "0b452d0d6cbe1c6b4e48796f21a4d4978d497711"
"img": "d0540819930d454dd272f9ee91739114",
"mask": "82738b790feeb3d762822cf13136abd5"
},
"WE_dual": {
"img": "7aeef4e6d692ee83ad0aae16e0722c1d3fbeee77",
"mask": "a7785e8139e83c3e67c33d264a34123a457f2d81"
"img": "0eb7042718b74b8973d8e945f0454867",
"mask": "88a5faacb4e5db2d7f5761066dc92f38"
},
"WE_anderson": {
"img": "4d9b3b7fdfc82d2835a4ccddcfa3a5398b3599f1",
"mask": "dcddd8fc6d9dc094561243fdee782b5a8986973f"
"img": "34284f8560d01e2231fe30b9362e8577",
"mask": "ec5671221e98b96b6b35622424266eaf"
},
"WE_howe": {
"img": "443054266c0049d4d6a7be5756e8427069931a68",
"mask": "a0b774261051a3570f8c3b7e7598fe03907f58ff"
"img": "f68a1210ae539a0dd4976bc8eaa701a8",
"mask": "c05d4411f96114b3b7ffe73254ff2875"
},
"WE_radial_thick_small": {
"img": "5623451adb178f560003b1d197507a3d15fbb9e3",
"mask": "3af91a81592f4e0f8da0fe7962a17f02d3209841"
"img": "b92d533177eed4a009625d6d2cb0da59",
"mask": "78da2d5ec63b48e53f5bdbd90d2b82b9"
},
"WE_radial_thick": {
"img": "01f0a078fc4b46425c513075f860277289cea1ce",
"mask": "dcf3e4ecf8a5299b71fcc0c0d5f2c3bbc4315d07"
"img": "d0067dfb57016354f7b107ae410d217c",
"mask": "482a1a903b54df01f3e16cb284b8bfeb"
},
"WE_radial_thin_small": {
"img": "c21abc112a9a0377a25fa0703a27cf5e669a4e0f",
"mask": "29e4c2cf98bd29ec115ee0c53345b7b0e3a56f48"
"img": "94e6b546f8ad5c6b95a502a8b409c00d",
"mask": "38a4da8d63237ac33b1a7f5e1cd021ec"
},
"WE_circular1": {
"img": "e869e5b38eee0e5eaff78a26550f2045d597ba4c",
"mask": "dec71151582ee939a93be088c3f6632724d278ba"
"img": "2ecc5cb5ad9cfef50de681ee3b923f46",
"mask": "32f876b2d56ce7a9f712f7784dc60289"
},
"WE_circular05": {
"img": "2931fe0b06b78b6af64d760541abb9a5e7432ea4",
"mask": "c531c2bcac8b2c059580bc737a3bd8122997831f"
"img": "5d09c011b57d3afffcaf82e7aea84b34",
"mask": "dde7cc1ee48b2d47b37fbe9422e0f677"
},
"WE_circular025": {
"img": "70e65b2bb8804fba76508e2c7f07dd25b2992f72",
"mask": "aa625abfc6258fc04855a7651c7bc7f8782cc632"
"img": "ec3feee88c49aed0a5554c3838be8519",
"mask": "e4e9c650c9a247180211dbcde0e38fb2"
},
"grating_induction": {
"img": "eabab5c78c8ed9232bf39f261715234cd2e77533",
"mask": "08c6127b6c91a55dc8500e032be85efd54a48753"
"img": "da62004fdc198660b44529f8b6358362",
"mask": "40f02639e692658b9f357b09c11e9df1"
},
"sbc_large": {
"img": "5dabe245b1ee1db04938b38df0a7d3f53d955a3c",
"mask": "e6003cfe3a131e0a383846d758bc7ce5fbe5dfb4"
"img": "8c1d036742bdf01159177f42625fe144",
"mask": "6f1f89e7d2a6d1b88c29c051ef3a2dd0"
},
"sbc_small": {
"img": "e3e54973cf56ac590ca3365f72a85c84c0406756",
"mask": "79453ba209c7fb0adb65d590b898f0016369c77a"
"img": "ae061d71fede147fcc8e7680e14e82c9",
"mask": "f4f124cbfae47fd81b7d398c09836495"
},
"todorovic_equal": {
"img": "c0fc1599d1d7daa40e3517de5c96bc7c639bc55c",
"mask": "2de52b9b0a17620a9d088315d734bcac799ee460"
"img": "caecfb4065b54222e8d810e00da685af",
"mask": "2821bec9b23503e1598696d0ab418f3b"
},
"todorovic_in_large": {
"img": "1cd13e2cafdf61b7afa39517dc3bb99d07c32932",
"mask": "ac5822f349faf5ab94a1ad84f2100036a6c051e5"
"img": "ba9c3382426f8e0e9864d4b999c7979c",
"mask": "265174ba6cc11c8a90fe9c822b18dfeb"
},
"todorovic_in_small": {
"img": "dfc311f76377593affa90b81821d3678ef68ec32",
"mask": "3706587cf15b34e24a5ec8059684723eee54980f"
"img": "0ab88dbeb1419b4b786134cc432d73d7",
"mask": "a711607fc494557ce2b52e984dc103b4"
},
"checkerboard_016": {
"img": "834d66b9a39b9d0671a03220ddb550b6ba459b00",
"mask": "7703068e11d77c270ebb79b6b3a15c9b0ba697a7"
"img": "cffb926181df5cea95608b95bbc163f1",
"mask": "1eb12e597ac5c454830dc2873730ccc1"
},
"checkerboard_0938": {
"img": "c8ccc332139c31ac5b79d917b6d30d8e104159d3",
"mask": "e7e491af5683983aa247eb9d6e83f3b1f6fb2511"
"img": "ffe0d07c218fa56eecce2a9386908ff5",
"mask": "845b86fd98823fc4778f76a360da6d52"
},
"checkerboard209": {
"img": "42036add90769ec09165a9cd0a405c2f337143af",
"mask": "d9c205103e37440e4fe4c7597d6eec512eb4764d"
"img": "3058e7c3d03899760fede8aba1c940ac",
"mask": "1172e323e0af65b431a4641be9836b7b"
},
"bullseye_thin": {
"img": "98355e157a00a402e8c3e1842e97a8649d629765",
"mask": "c13467fe9d2d45cc8bedc40342c8801e0f3bdd68"
"img": "59c97cb1feffb4c9c502b143c5699fb3",
"mask": "08cfee34814f232afda08e138da10661"
},
"bullseye_thick": {
"img": "98355e157a00a402e8c3e1842e97a8649d629765",
"mask": "c13467fe9d2d45cc8bedc40342c8801e0f3bdd68"
"img": "59c97cb1feffb4c9c502b143c5699fb3",
"mask": "08cfee34814f232afda08e138da10661"
}
}
48 changes: 24 additions & 24 deletions tests/papers/domijan2015.json
@@ -1,50 +1,50 @@
{
"dungeon": {
"img": "68916765508edad21b54a739c439d9f3ed0818f9",
"mask": "2909a91b9e41ce0d2c34bedc3dcc5498387711f4"
"img": "23859250c9f5a895de48c20e7095f4e9",
"mask": "1954462ad5eeb864935b349630f918f9"
},
"cube": {
"img": "c0f97e35df4d0dc83b853592deb4b0b7edad9ead",
"mask": "8e1b08b9cbbdd21ddb43cfb5d1cd2a709e41587f"
"img": "59ac0095ba9c17a2cdd98ffff6613447",
"mask": "3a6543daa69e82047d0b84b76a446312"
},
"grating": {
"img": "ad412900c2876353b05946983b45616fc1491fc0",
"mask": "ffbdfa00d199b3c0b8b1591d959688edb7af5d6e"
"img": "44286e04ca4f44fe98930722c0d45b1a",
"mask": "cb796a47e9ca6c8426a2585c9b604989"
},
"rings": {
"img": "05405135800f940595d878684a22ebc7526010b1",
"mask": "62077c54c04844f489d856073fa8751173ec047d"
"img": "38a7bc014428864fffcee590d0953465",
"mask": "3c5c395de3b4cae5b6956314624ea012"
},
"bullseye": {
"img": "f08bcba5900de35e14d0c7e9c3e39606008df996",
"mask": "995024b44d54a04a2c408c41e156c4b0cf128611"
"img": "e30fb79cf7897dfed4ce04983b36ba28",
"mask": "721937af54e313931f38a22b7a6ce885"
},
"simultaneous_brightness_contrast": {
"img": "7278d19b967f4b11054d0fe95fee5d96bed1e075",
"mask": "7d542f0409c187c2bb50043dd76f13174071788e"
"img": "a0e0353cd1fb9a829241ddecc51fbc64",
"mask": "c46a87aa52c48192ce96c90fbe10c062"
},
"white": {
"img": "73e3daae2ad8bde2a5bf8e2a2a13fe52988c48ce",
"mask": "2eefb2dc02de0e4733d25d7ce682d7417abb55e2"
"img": "377a2903002d526da2ba1d052eb193d2",
"mask": "306423f9e89e6d3bd21a946881ef684a"
},
"benary": {
"img": "79e232c02f5086b3bd7e56caf63b7ae0fa1db64b",
"mask": "5b0b04f0af4abec321f4fd7802e63d29e0062264"
"img": "4c3f2278ac91effebf1db9f580a24db6",
"mask": "c790aa14edddb57f8054a4f330c7ddc6"
},
"todorovic": {
"img": "0a00ab245563dda224877f93e3c8e956a419e56d",
"mask": "245263ceb96d1fbdd379661ca2fbc134a89dfd92"
"img": "1b9d5b09475aace9b97f599c5731177b",
"mask": "2eeeeb428daf6be031c64ef841e7c897"
},
"checkerboard_contrast_contrast": {
"img": "92246df5d992e6479aac62ecb2eaf85d0693d532",
"mask": "765a19c96b4cbe020ab09fde08e4a9ddb86847e7"
"img": "246c282926e1a0b390eb4bca6bd00b16",
"mask": "487c5cbe9dfd08719ead98ea9a7e901c"
},
"checkerboard": {
"img": "b66cfcf6e0de943f62e3d69db78a8d1eb7e06c21",
"mask": "684eb135d09c6810d8b06d4983b3017f2c31d592"
"img": "6891d301caf87043b99c199f13fdf607",
"mask": "70844521cd62275df0cab9a7c1184d9d"
},
"checkerboard_extended": {
"img": "9f102bb9e7252041485506b8d820150944714520",
"mask": "f7dd09bb19ad64e178ea280bf9ebb08534ef2972"
"img": "570e9597fa49a33a6e96687a007ad3e0",
"mask": "f6ee08aeab807602449271ee7367cc44"
}
}
8 changes: 4 additions & 4 deletions tests/papers/gen_ground_truth.py
@@ -1,5 +1,5 @@
import json
from hashlib import sha1
from hashlib import md5

import numpy as np
from stimuli.papers import *
Expand All @@ -24,9 +24,9 @@ def gen_ground_truth(paper):
# Generate the stimulus-dict
stim = func()

# Hash (sha1) "img" and "mask", and save only the hex
stim["img"] = sha1(np.ascontiguousarray(stim["img"])).hexdigest()
stim["mask"] = sha1(np.ascontiguousarray(stim["mask"])).hexdigest()
# Hash (md5) "img" and "mask", and save only the hex
stim["img"] = md5(np.ascontiguousarray(stim["img"])).hexdigest()
stim["mask"] = md5(np.ascontiguousarray(stim["mask"])).hexdigest()

# Accumulate
stims[stimname] = stim
Expand Down
48 changes: 24 additions & 24 deletions tests/papers/murray2020.json
@@ -1,50 +1,50 @@
{
"argyle": {
"img": "423e122e42b54fce9917f3c617fab6f4b2f0d18a",
"mask": "06e66f7b979c14c0986d165237796d819a15cff2"
"img": "cb4ed25c9e5d878c4daf41a57656e4ba",
"mask": "b9c1760d980dc13c5bb2fda8ebe537c2"
},
"argyle_control": {
"img": "49ff3ef8cd53b2426d26c4df3bc1466f6f29c08f",
"mask": "5259c98174257af732e9b348d642ae1e4747d2ac"
"img": "e3e1e33d7eb3f1e4ea2c0100e551b3e6",
"mask": "91dbc28e28a6209bcd187a11e0321cae"
},
"argyle_long": {
"img": "c21fab6e5c7fabd1952cd822340510ca7434c6a1",
"mask": "408fb07d203a9a747b64b780d7fd225c34104523"
"img": "ce09cf6536bc04037536c767c973ef9c",
"mask": "83ffc7391ddcbebfe6cec7b0944c6dc0"
},
"snake": {
"img": "d29f91b88c29dfb6976ef861bf281983416ad3c4",
"mask": "cb9ba76ba9fbd80dfb6b812d503f4f3c002db1bd"
"img": "06337656c123eeb36dd75963639adaa2",
"mask": "02636e9e6289b9ae0bb36e518fc20e3f"
},
"snake_control": {
"img": "5d65036b27e6eb14441886c153a2ac8b2512e1b3",
"mask": "cb9ba76ba9fbd80dfb6b812d503f4f3c002db1bd"
"img": "3473bf614bdf0eb68b4c7c8ce1b29697",
"mask": "02636e9e6289b9ae0bb36e518fc20e3f"
},
"koffka_adelson": {
"img": "8c99e0b6208753c2cd0a3ef16c03833ad9c549f3",
"mask": "0a20a73294a86ff18f40f29ab32dd9f92cd486e5"
"img": "16f09cb37a170053a73f5183f289b6df",
"mask": "ecf8713ae03549fa9ee16b1462ff5bf1"
},
"koffka_broken": {
"img": "18e94511fd09c8fc8db9b73e75a451e296db4b81",
"mask": "3f8d7213e374a03226e86321bfca0bdc60effacf"
"img": "f710a7d1ceb75d1f6cac9d91e1c2a821",
"mask": "40c249e4d8835580b7f57d04e0df65c4"
},
"koffka_connected": {
"img": "50e6083439a1f8d6e03740f1e7e4b3964b35574f",
"mask": "347e20673d19f639e9c7b6d52947c2000266d609"
"img": "9ffb69c20afbaf731877b4626d61c404",
"mask": "4e4fa0cbe12df9fa7bdab6b0fc073270"
},
"checkassim": {
"img": "bc1580ef30dd5d1286fac394eeddc1eec4b73f9f",
"mask": "3db7cac46499b5e7e18a8a121194f1488ddaaa71"
"img": "ef5b9b410280b3f2e2ff45ee165e32d7",
"mask": "4bc92371e105629f30513c1050f99cf4"
},
"simcon": {
"img": "52f4d6d39d655994cd9da9cfc28fa24630339907",
"mask": "343b00af32adab0fd0a333b9adbda3f8b3ff0f8e"
"img": "87da2163dcd4ce3ef214c48fa243c787",
"mask": "99fbc73e5c8aefd70501838130b806e9"
},
"simcon_articulated": {
"img": "adfa71c170c756965cd9b323c5e2ba19cd42e37a",
"mask": "343b00af32adab0fd0a333b9adbda3f8b3ff0f8e"
"img": "61685f75a7352ff756d566a6ffcc8faf",
"mask": "99fbc73e5c8aefd70501838130b806e9"
},
"white": {
"img": "5bfa344de8ce975c538c58209bc2a2b81e535d34",
"mask": "ebecf00e9fe472f1b1f429b5e64d8a0130739b3f"
"img": "0fb691c397d4bdcbb0eb5f89134be5aa",
"mask": "b0f4ec00fd2d12d15f005af9b53b29f8"
}
}
6 changes: 3 additions & 3 deletions tests/papers/test_RHS2007.py
@@ -1,6 +1,6 @@
import json
import os.path
from hashlib import sha1
from hashlib import md5

import pytest
import stimuli.papers.RHS2007
Expand All @@ -15,8 +15,8 @@
def test_stim(stim):
func = getattr(stimuli.papers.RHS2007, stim)
assert (
sha1(func()["img"]).hexdigest() == loaded[stim]["img"]
md5(func()["img"]).hexdigest() == loaded[stim]["img"]
), "imgs are different"
assert (
sha1(func()["mask"]).hexdigest() == loaded[stim]["mask"]
md5(func()["mask"]).hexdigest() == loaded[stim]["mask"]
), "masks are different"
6 changes: 3 additions & 3 deletions tests/papers/test_domijan2015.py
@@ -1,6 +1,6 @@
import json
import os.path
from hashlib import sha1
from hashlib import md5

import pytest
import stimuli.papers.domijan2015
Expand All @@ -15,8 +15,8 @@
def test_stim(stim):
func = getattr(stimuli.papers.domijan2015, stim)
assert (
sha1(func()["img"]).hexdigest() == loaded[stim]["img"]
md5(func()["img"]).hexdigest() == loaded[stim]["img"]
), "imgs are different"
assert (
sha1(func()["mask"]).hexdigest() == loaded[stim]["mask"]
md5(func()["mask"]).hexdigest() == loaded[stim]["mask"]
), "masks are different"
6 changes: 3 additions & 3 deletions tests/papers/test_murray2020.py
@@ -1,6 +1,6 @@
import json
import os.path
from hashlib import sha1
from hashlib import md5

import numpy as np
import pytest
Expand All @@ -16,10 +16,10 @@
def test_stim(stim):
func = getattr(stimuli.papers.murray2020, stim)
assert (
sha1(np.ascontiguousarray(func()["img"])).hexdigest()
md5(np.ascontiguousarray(func()["img"])).hexdigest()
== loaded[stim]["img"]
), "imgs are different"
assert (
sha1(np.ascontiguousarray(func()["mask"])).hexdigest()
md5(np.ascontiguousarray(func()["mask"])).hexdigest()
== loaded[stim]["mask"]
), "masks are different"

0 comments on commit 611a1bf

Please sign in to comment.