-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make release-tag: Merge branch 'main' into stable
- Loading branch information
Showing
16 changed files
with
285 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,12 +47,12 @@ make install | |
|
||
If you intend to modify the source code or contribute to the project you will need to | ||
install it from the source using the `make install-develop` command. In this case, we | ||
recommend you to branch from `master` first: | ||
recommend you to branch from `main` first: | ||
|
||
```bash | ||
git clone [email protected]:sdv-dev/Copulas | ||
cd Copulas | ||
git checkout master | ||
git checkout main | ||
git checkout -b <your-branch-name> | ||
make install-develp | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,18 @@ | |
|
||
__author__ = 'DataCebo, Inc.' | ||
__email__ = '[email protected]' | ||
__version__ = '0.9.1' | ||
__version__ = '0.9.2.dev1' | ||
|
||
import contextlib | ||
import importlib | ||
import sys | ||
import warnings | ||
from copy import deepcopy | ||
from operator import attrgetter | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
from copulas._addons import _find_addons | ||
|
||
_find_addons(group='copulas_modules', parent_globals=globals()) | ||
from pkg_resources import iter_entry_points | ||
|
||
EPSILON = np.finfo(np.float32).eps | ||
|
||
|
@@ -262,3 +262,71 @@ def decorated(self, X, *args, **kwargs): | |
return function(self, X, *args, **kwargs) | ||
|
||
return decorated | ||
|
||
|
||
def _get_addon_target(addon_path_name): | ||
"""Find the target object for the add-on. | ||
Args: | ||
addon_path_name (str): | ||
The add-on's name. The add-on's name should be the full path of valid Python | ||
identifiers (i.e. importable.module:object.attr). | ||
Returns: | ||
tuple: | ||
* object: | ||
The base module or object the add-on should be added to. | ||
* str: | ||
The name the add-on should be added to under the module or object. | ||
""" | ||
module_path, _, object_path = addon_path_name.partition(':') | ||
module_path = module_path.split('.') | ||
|
||
if module_path[0] != __name__: | ||
msg = f"expected base module to be '{__name__}', found '{module_path[0]}'" | ||
raise AttributeError(msg) | ||
|
||
target_base = sys.modules[__name__] | ||
for submodule in module_path[1:-1]: | ||
target_base = getattr(target_base, submodule) | ||
|
||
addon_name = module_path[-1] | ||
if object_path: | ||
if len(module_path) > 1 and not hasattr(target_base, module_path[-1]): | ||
msg = f"cannot add '{object_path}' to unknown submodule '{'.'.join(module_path)}'" | ||
raise AttributeError(msg) | ||
|
||
if len(module_path) > 1: | ||
target_base = getattr(target_base, module_path[-1]) | ||
|
||
split_object = object_path.split('.') | ||
addon_name = split_object[-1] | ||
|
||
if len(split_object) > 1: | ||
target_base = attrgetter('.'.join(split_object[:-1]))(target_base) | ||
|
||
return target_base, addon_name | ||
|
||
|
||
def _find_addons(): | ||
"""Find and load all copulas add-ons.""" | ||
group = 'copulas_modules' | ||
for entry_point in iter_entry_points(group=group): | ||
try: | ||
addon = entry_point.load() | ||
except Exception: # pylint: disable=broad-exception-caught | ||
msg = f'Failed to load "{entry_point.name}" from "{entry_point.module_name}".' | ||
warnings.warn(msg) | ||
continue | ||
|
||
try: | ||
addon_target, addon_name = _get_addon_target(entry_point.name) | ||
except AttributeError as error: | ||
msg = f"Failed to set '{entry_point.name}': {error}." | ||
warnings.warn(msg) | ||
continue | ||
|
||
setattr(addon_target, addon_name, addon) | ||
|
||
|
||
_find_addons() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.