Merge branch 'develop' into hyperopt-adaptive-roi-space

This commit is contained in:
hroff-1902
2019-08-20 23:00:23 +03:00
committed by GitHub
55 changed files with 1583 additions and 813 deletions

View File

@@ -5,11 +5,11 @@ import gzip
import logging
import re
from datetime import datetime
from pathlib import Path
import numpy as np
import rapidjson
logger = logging.getLogger(__name__)
@@ -39,7 +39,7 @@ def datesarray_to_datetimearray(dates: np.ndarray) -> np.ndarray:
return dates.dt.to_pydatetime()
def file_dump_json(filename, data, is_zip=False) -> None:
def file_dump_json(filename: Path, data, is_zip=False) -> None:
"""
Dump JSON data into a file
:param filename: file to create
@@ -49,8 +49,8 @@ def file_dump_json(filename, data, is_zip=False) -> None:
logger.info(f'dumping json to "{filename}"')
if is_zip:
if not filename.endswith('.gz'):
filename = filename + '.gz'
if filename.suffix != '.gz':
filename = filename.with_suffix('.gz')
with gzip.open(filename, 'w') as fp:
rapidjson.dump(data, fp, default=str, number_mode=rapidjson.NM_NATIVE)
else: