Skip to content

utils module

add(x, y)

Add two given numbers

Parameters:

Name Type Description Default
x int/float

description

required
y int/float

description

required
Source code in geodemora/utils.py
16
17
18
19
20
21
22
23
def add(x, y):
    """Add two given numbers

    Args:
        x (int/float): _description_
        y (int/float): _description_
    """
    return x + y

multiply(x, y)

Multiply two numbers

Parameters:

Name Type Description Default
x int/float

description

required
y int/float

description

required
Source code in geodemora/utils.py
34
35
36
37
38
39
40
41
def multiply(x, y):
    """Multiply two numbers

    Args:
        x (int/float): _description_
        y (int/float): _description_
    """
    return x * y

random_string(string_length=3, use_seed=False)

Generates a random string of fixed length.

Parameters:

Name Type Description Default
string_length int

Fixed length. Defaults to 3.

3

Returns:

Name Type Description
str

A random string

Source code in geodemora/utils.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def random_string(string_length=3, use_seed = False):
    """Generates a random string of fixed length.
    Args:
        string_length (int, optional): Fixed length. Defaults to 3.
    Returns:
        str: A random string
    """
    import random
    import string

    if use_seed:
        random.seed(1001)
    letters = string.ascii_lowercase
    return "".join(random.choice(letters) for i in range(string_length))

subtract(x, y)

Subtract y from x.

Parameters:

Name Type Description Default
x int/float

description

required
y int/float

description

required
Source code in geodemora/utils.py
25
26
27
28
29
30
31
32
def subtract(x, y):
    """Subtract y from x.

    Args:
        x (int/float): _description_
        y (int/float): _description_
    """
    return x - y

Last update: 2022-06-06