MCPcopy Create free account
hub / github.com/PyTables/PyTables / __init__

Method __init__

tables/file.py:761–863  ·  view source on GitHub ↗
(
        self,
        filename: str,
        mode: Literal["r", "w", "a", "r+"] = "r",
        title: str = "",
        root_uep: str = "/",
        filters: Filters | None = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

759 del self.root._v_filters
760
761 def __init__(
762 self,
763 filename: str,
764 mode: Literal["r", "w", "a", "r+"] = "r",
765 title: str = "",
766 root_uep: str = "/",
767 filters: Filters | None = None,
768 **kwargs,
769 ) -> None:
770
771 self.filename = os.fspath(filename)
772 """The name of the opened file."""
773
774 self.mode = mode
775 """The mode in which the file was opened."""
776
777 if mode not in ("r", "r+", "a", "w"):
778 raise ValueError(
779 "invalid mode string ``%s``. Allowed modes are: "
780 "'r', 'r+', 'a' and 'w'" % mode
781 )
782
783 # Get all the parameters in parameter file(s)
784 params = {
785 k: v
786 for k, v in parameters.__dict__.items()
787 if k.isupper() and not k.startswith("_")
788 }
789 # Update them with possible keyword arguments
790 if [k for k in kwargs if k.isupper()]:
791 warnings.warn(
792 "The use of uppercase keyword parameters is " "deprecated",
793 DeprecationWarning,
794 )
795
796 kwargs = {k.upper(): v for k, v in kwargs.items()}
797 params.update(kwargs)
798
799 # If MAX_ * _THREADS is not set yet, set it to the number of cores
800 # on this machine.
801
802 if params["MAX_NUMEXPR_THREADS"] is None:
803 params["MAX_NUMEXPR_THREADS"] = detect_number_of_cores()
804
805 if params["MAX_BLOSC_THREADS"] is None:
806 params["MAX_BLOSC_THREADS"] = detect_number_of_cores()
807
808 self.params = params
809
810 # Now, it is time to initialize the File extension
811 self._g_new(filename, mode, **params)
812
813 # Check filters and set PyTables format version for new files.
814 new = self._v_new
815 if new:
816 _checkfilters(filters)
817 self.format_version = format_version
818 """The PyTables version number of this file."""

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 11

__get_root_groupMethod · 0.95
enable_undoMethod · 0.95
detect_number_of_coresFunction · 0.85
_checkfiltersFunction · 0.85
NodeManagerClass · 0.85
_g_newMethod · 0.80
_g__setattrMethod · 0.80
itemsMethod · 0.45
updateMethod · 0.45
addMethod · 0.45
_g_post_init_hookMethod · 0.45

Tested by

no test coverage detected