Created
August 14, 2020 13:22
-
-
Save thesamovar/1b565d288607b004cc0e08086b5b5046 to your computer and use it in GitHub Desktop.
Hack to load pickled file in Manis et al. 2019 cochlear nucleus data on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# obscene hack to load the data from https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0223137 | |
from pathlib import WindowsPath, PosixPath, Path | |
def hacked_new(cls, *args, **kwargs): | |
if cls is Path: | |
cls = WindowsPath if os.name == 'nt' else PosixPath | |
self = cls._from_parts(args, init=False) | |
# this line causes a problem | |
# if not self._flavour.is_supported: | |
# raise NotImplementedError("cannot instantiate %r on your system" | |
# % (cls.__name__,)) | |
self._init() | |
return self | |
old_Path_new = Path.__new__ | |
Path.__new__ = hacked_new # replace problematic method temporarily | |
data = pickle.load(open('LDA_data.pkl', 'rb')) | |
Path.__new__ = old_Path_new # restore old |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment