syft.lib package¶
Subpackages¶
- syft.lib.misc package
- syft.lib.numpy package
- syft.lib.python package
- Subpackages
- Submodules
- syft.lib.python.bool module
- syft.lib.python.bytes module
- syft.lib.python.complex module
- syft.lib.python.dict module
- syft.lib.python.float module
- syft.lib.python.int module
- syft.lib.python.iterator module
- syft.lib.python.list module
- syft.lib.python.none module
- syft.lib.python.primitive_container module
- syft.lib.python.primitive_factory module
- syft.lib.python.primitive_interface module
- syft.lib.python.range module
- syft.lib.python.set module
- syft.lib.python.slice module
- syft.lib.python.string module
- syft.lib.python.tuple module
- syft.lib.python.types module
- syft.lib.python.util module
- syft.lib.torch package
Submodules¶
syft.lib.util module¶
- syft.lib.util.is_static_method(klass, attr)[source]¶
Test if a value of a class is static method.
Example:
class MyClass(object): @staticmethod def method(): ...
- Parameters
klass (type) – the class on which we want to check whether the method is statically implemented
attr (str) – the name of the method we want to check.
- Returns
whether or not a method named <attr> is a static method of class <klass>
- Return type
bool
- syft.lib.util.copy_static_methods(from_class, to_class)[source]¶
Copies all static methods from one class to another class
This utility was initialized during the creation of the Constructor for PyTorch’s “th.Tensor” class. Since we replace each original constructor (th.Tensor) with on we implement (torch.UppercaseTensorConstructor), we also need to make sure that our new constructor has any static methods which were previously stored on th.Tensor. Otherwise, the library might look for them there, not find them, and then trigger an error.
- Parameters
from_class (Type) – the class on which we look for static methods co copy
to_class (Type) – the class onto which we copy all static methods found in <from_class>
- syft.lib.util.get_original_constructor_name(object_name)[source]¶
Generate name for original constructor
For each custom constructor, we move the original constructor to a consistent location relative to the original constructor so that each custom constructor automatically knows where to find the original method it is overloading. Namely, we move the original constructor to a different attr within the same module as the original constructor. This method specifies the naming convention that we use to name the original constructor when it is moved.
- Args:
object_name (str): the original constructor’s original name
- syft.lib.util.replace_classes_in_module(module, from_class, to_class, ignore_prefix=None)[source]¶
Recursively replace occurrence of from_class to to_class inside module.
For example, when syft replaces torch.nn.parameter.Parameter constructor, there’s also need to replace the same constructor in other modules that has already imported it.
- Parameters
module (ModuleType) – top-level module to traverse
from_class – Original constructor
to_class – syft’s ObjectConstructor