-
Notifications
You must be signed in to change notification settings - Fork 111
/
dtypes.py
30 lines (26 loc) · 1.17 KB
/
dtypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright (c) 2019-2020, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.
import numpy as np
from packaging import version
try:
from importlib.metadata import distribution
except ModuleNotFoundError:
# not available in python 3.7
from importlib_metadata import distribution
NUMPY_VERSION = version.parse(distribution('numpy').version)
_MAX_NUMPY_VERSION_NPINT = version.parse("1.20.0")
dt_int = (
np.int32
) # dtype('int64') or dtype('int32') depending on platform => i force it to int32
dt_float = (
np.float32
) # dtype('float64') or dtype('float32') depending on platform => i force it to float32
dt_bool = np.bool_ # mandatory for numpy >= 1.24
int_types = (int, dt_int, np.int64)
if NUMPY_VERSION <= _MAX_NUMPY_VERSION_NPINT:
int_types = (int, dt_int, np.int64, np.int)