Skip to content

Convert import_object to get_instance #114

Closed

Description

@csala

Rename the import_object function to get_instance and make it accept both a string, a class and an instance, as well as arbitrary additional keyword arguments.

If an instance is given, a new unfitted instance should be created with the same arguments.

One should be able to do this:

from copulas import get_instance

instance1 = get_instance('copulas.univariate.gaussian.GaussianUnivariate', some=kwargs)
instance2 = get_instance(instance1.__class__, some=kwargs)
instance3 = get_instance(instance2)
instance3.fit(data)
instance4 = get_instance(instance3)

In all cases, the output from the get_instance calls should be exactly the same as in:

form copulas.univariate.gaussian import GaussianUnivariate

instance = GaussianUnivariate(some=kwargs)

In the edge case where an instance is given alongside some keyword arguments, these should overwrite the ones from the instance:

So, for example, this would be valid and create an instance with a different keyword argument value:

instance5 = get_instance(instance4, some=other_kwargs)

Activity

  1. added this to the 0.2.4 milestone on Dec 20, 2019
  2. modified the milestones: 0.2.4, 0.2.5 on Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions