Skip to content

Commit

Permalink
Refactor to Python3 style
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwill authored and you-n-g committed Dec 15, 2020
1 parent 192c2dc commit 3f85af0
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/benchmarks/TFT/expt_settings/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import data_formatters.qlib_Alpha158


class ExperimentConfig(object):
class ExperimentConfig:
"""Defines experiment configs and paths to outputs.
Attributes:
Expand Down
6 changes: 3 additions & 3 deletions examples/benchmarks/TFT/libs/tft_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def __call__(self, q, k, v, mask=None):
return outputs, attn


class TFTDataCache(object):
class TFTDataCache:
"""Caches data for the TFT."""

_data_cache = {}
Expand Down Expand Up @@ -348,7 +348,7 @@ def contains(cls, key):


# TFT model definitions.
class TemporalFusionTransformer(object):
class TemporalFusionTransformer:
"""Defines Temporal Fusion Transformer.
Attributes:
Expand Down Expand Up @@ -972,7 +972,7 @@ def build_model(self):
valid_quantiles = self.quantiles
output_size = self.output_size

class QuantileLossCalculator(object):
class QuantileLossCalculator:
"""Computes the combined quantile loss for prespecified quantiles.
Attributes:
Expand Down
1 change: 0 additions & 1 deletion qlib/contrib/backtest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# -*- coding: utf-8 -*-
from .order import Order
from .account import Account
from .position import Position
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/model/pytorch_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def load(self, buffer, **kwargs):
self._fitted = True


class AverageMeter(object):
class AverageMeter:
"""Computes and stores the average and current value"""

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/model/pytorch_sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def predict(self, dataset):
return pd.Series(np.concatenate(preds), index=index)


class AverageMeter(object):
class AverageMeter:
"""Computes and stores the average and current value"""

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/online/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .executor import save_score_series, load_score_series


class Operator(object):
class Operator:
def __init__(self, client: str):
"""
Parameters
Expand Down
4 changes: 2 additions & 2 deletions qlib/contrib/report/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ...utils import get_module_by_module_path


class BaseGraph(object):
class BaseGraph:
""""""

_name = None
Expand Down Expand Up @@ -204,7 +204,7 @@ def _get_data(self):
return _data


class SubplotsGraph(object):
class SubplotsGraph:
"""Create subplots same as df.plot(subplots=True)
Simple package for `plotly.tools.subplots`
Expand Down
6 changes: 3 additions & 3 deletions qlib/contrib/tuner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os


class TunerConfigManager(object):
class TunerConfigManager:
def __init__(self, config_path):

if not config_path:
Expand All @@ -27,7 +27,7 @@ def __init__(self, config_path):
self.qlib_client_config = config.get("qlib_client", dict())


class PipelineExperimentConfig(object):
class PipelineExperimentConfig:
def __init__(self, config, TUNER_CONFIG_MANAGER):
"""
:param config: The config dict for tuner experiment
Expand All @@ -53,7 +53,7 @@ def __init__(self, config, TUNER_CONFIG_MANAGER):
yaml.dump(TUNER_CONFIG_MANAGER.config, fp)


class OptimizationConfig(object):
class OptimizationConfig:
def __init__(self, config, TUNER_CONFIG_MANAGER):

self.report_type = config.get("report_type", "pred_long")
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/tuner/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ...utils import get_module_by_module_path


class Pipeline(object):
class Pipeline:

GLOBAL_BEST_PARAMS_NAME = "global_best_params.json"

Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/tuner/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from hyperopt import STATUS_OK, STATUS_FAIL


class Tuner(object):
class Tuner:
def __init__(self, tuner_config, optim_config):

self.logger = get_module_logger("Tuner", sh_level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion qlib/data/_libs/expanding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from libc.math cimport sqrt, isnan, NAN
from libcpp.vector cimport vector


cdef class Expanding(object):
cdef class Expanding:
"""1-D array expanding"""
cdef vector[double] barv
cdef int na_count
Expand Down
2 changes: 1 addition & 1 deletion qlib/data/_libs/rolling.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from libc.math cimport sqrt, isnan, NAN
from libcpp.deque cimport deque


cdef class Rolling(object):
cdef class Rolling:
"""1-D array rolling"""
cdef int window
cdef deque[double] barv
Expand Down
6 changes: 3 additions & 3 deletions qlib/data/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _check_size_limit(self):
self.popitem(last=False)


class MemCache(object):
class MemCache:
"""Memory cache."""

def __init__(self, mem_cache_size_limit=None, limit_type="length"):
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_cache(mem_cache, key):
return value, expire


class CacheUtils(object):
class CacheUtils:
LOCK_ID = "QLIB"

@staticmethod
Expand Down Expand Up @@ -224,7 +224,7 @@ def writer_lock(redis_t, lock_name):
current_cache_wlock.release()


class BaseProviderCache(object):
class BaseProviderCache:
"""Provider cache base class"""

def __init__(self, provider):
Expand Down
2 changes: 1 addition & 1 deletion qlib/data/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pickle


class Client(object):
class Client:
"""A client class
Provide the connection tool functions for ClientProvider.
Expand Down
2 changes: 1 addition & 1 deletion qlib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_module_logger(module_name, level=None):
return module_logger


class TimeInspector(object):
class TimeInspector:

timer_logger = get_module_logger("timer", level=logging.WARNING)

Expand Down
2 changes: 1 addition & 1 deletion qlib/portfolio/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Optional, Union, Callable, List


class PortfolioOptimizer(object):
class PortfolioOptimizer:
"""Portfolio Optimizer
The following optimization algorithms are supported:
Expand Down
2 changes: 1 addition & 1 deletion qlib/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def flatten_dict(d, parent_key="", sep="."):


#################### Wrapper #####################
class Wrapper(object):
class Wrapper:
"""Wrapper class for anything that needs to set up during qlib.init"""

def __init__(self):
Expand Down

0 comments on commit 3f85af0

Please sign in to comment.