mirror of
https://github.com/sbrl/research-rainfallradar
synced 2024-11-24 18:23:01 +00:00
move shuffle to subdir
This commit is contained in:
parent
2edfb1a21f
commit
0b676fa391
4 changed files with 21 additions and 3 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
|
|
18
aimodel/src/lib/dataset/primitives/shuffle.py
Normal file
18
aimodel/src/lib/dataset/primitives/shuffle.py
Normal 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
|
Loading…
Reference in a new issue