move shuffle to subdir

This commit is contained in:
Starbeamrainbowlabs 2023-01-13 16:47:35 +00:00
parent 2edfb1a21f
commit 0b676fa391
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 21 additions and 3 deletions

View file

@ -9,7 +9,7 @@ import tensorflow as tf
from lib.dataset.read_metadata import read_metadata from lib.dataset.read_metadata import read_metadata
from ..io.readfile import readfile from ..io.readfile import readfile
from .shuffle import shuffle from .primitives.shuffle import shuffle

View file

@ -9,7 +9,7 @@ import tensorflow as tf
from lib.dataset.read_metadata import read_metadata from lib.dataset.read_metadata import read_metadata
from ..io.readfile import readfile from ..io.readfile import readfile
from .shuffle import shuffle from .primitives.shuffle import shuffle
from .parse_heightmap import parse_heightmap from .parse_heightmap import parse_heightmap

View file

@ -7,7 +7,7 @@ import tensorflow as tf
from lib.dataset.read_metadata import read_metadata from lib.dataset.read_metadata import read_metadata
from ..io.readfile import readfile from ..io.readfile import readfile
from .shuffle import shuffle from .primitives.shuffle import shuffle
# TO PARSE: # TO PARSE:

View file

@ -0,0 +1,18 @@
from copy import deepcopy
from random import randint
def shuffle(lst):
"""
Shuffles a list with the Fisher-Yates algorithm.
@ref https://poopcode.com/shuffle-a-list-in-python-fisher-yates/
@param lst list The list to shuffle.
@return list The a new list that is a shuffled copy of the original.
"""
tmplist = deepcopy(lst)
m = len(tmplist)
while (m):
m -= 1
i = randint(0, m)
tmplist[m], tmplist[i] = tmplist[i], tmplist[m]
return tmplist