{"record":{"id":"1caff0db2ce5c276","repo":"microsoft/qlib","slug":"limit-type-must-be-length-or-sizeof-your-limit-ty","errorCode":null,"errorMessage":"limit_type must be length or sizeof, your limit_type is {limit_type}","messagePattern":"limit_type must be length or sizeof, your limit_type is (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/cache.py","lineNumber":159,"sourceCode":"        \"\"\"\n\n        Parameters\n        ----------\n        mem_cache_size_limit:\n            cache max size.\n        limit_type:\n            length or sizeof; length(call fun: len), size(call fun: sys.getsizeof).\n        \"\"\"\n\n        size_limit = C.mem_cache_size_limit if mem_cache_size_limit is None else mem_cache_size_limit\n        limit_type = C.mem_cache_limit_type if limit_type is None else limit_type\n\n        if limit_type == \"length\":\n            klass = MemCacheLengthUnit\n        elif limit_type == \"sizeof\":\n            klass = MemCacheSizeofUnit\n        else:\n            raise ValueError(f\"limit_type must be length or sizeof, your limit_type is {limit_type}\")\n\n        self.__calendar_mem_cache = klass(size_limit)\n        self.__instrument_mem_cache = klass(size_limit)\n        self.__feature_mem_cache = klass(size_limit)\n\n    def __getitem__(self, key):\n        if key == \"c\":\n            return self.__calendar_mem_cache\n        elif key == \"i\":\n            return self.__instrument_mem_cache\n        elif key == \"f\":\n            return self.__feature_mem_cache\n        else:\n            raise KeyError(\"Unknown memcache unit\")\n\n    def clear(self):\n        self.__calendar_mem_cache.clear()\n        self.__instrument_mem_cache.clear()","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/cache.py#L141-L177","documentation":"Error \"limit_type must be length or sizeof, your limit_type is {limit_type}\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/data/cache.py:159 when the guard condition fails: \"limit_type must be length or sizeof, your limit_type is {limit_type}\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Set limit_type to either 'length' or 'sizeof' in your cache configuration.","Fix the limit_type value in your qlib config: it must be the string 'length' or 'sizeof'."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}