Skip to content

Commit

Permalink
Studio2: Remove duplications from api/utils.py (#2035)
Browse files Browse the repository at this point in the history
* Remove duplicate os import
* Remove duplicate parse_seed_input function
  • Loading branch information
one-lithe-rune authored and monorimet committed Dec 12, 2023
1 parent 6f47bcd commit b197df6
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions apps/shark_studio/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import sys
import os
import numpy as np
import glob
import json
from random import (
randint,
seed as seed_random,
Expand Down Expand Up @@ -354,28 +354,6 @@ def get_devices_by_name(driver_name):
return available_devices


# take a seed expression in an input format and convert it to
# a list of integers, where possible
def parse_seed_input(seed_input: str | list | int):
if isinstance(seed_input, str):
try:
seed_input = json.loads(seed_input)
except (ValueError, TypeError):
seed_input = None

if isinstance(seed_input, int):
return [seed_input]

if isinstance(seed_input, list) and all(
type(seed) is int for seed in seed_input
):
return seed_input

raise TypeError(
"Seed input must be an integer or an array of integers in JSON format"
)


# Generate and return a new seed if the provided one is not in the
# supported range (including -1)
def sanitize_seed(seed: int | str):
Expand Down

0 comments on commit b197df6

Please sign in to comment.