# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class DBSCANParams(BaseModel):
    """
    Parameters for DBSCAN clustering algorithm.
    """ # noqa: E501
    eps: Optional[Union[StrictFloat, StrictInt]] = Field(default=0.5, description="Maximum distance between two samples for one to be considered in the neighborhood of the other")
    min_samples: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=5, description="Number of samples in a neighborhood for a point to be considered a core point")
    metric: Optional[StrictStr] = Field(default='euclidean', description="Metric to use for distance computation")
    metric_params: Optional[Dict[str, Any]] = Field(default=None, description="Additional keyword arguments for the metric function")
    algorithm: Optional[StrictStr] = Field(default='auto', description="Algorithm to compute pointwise distances and find nearest neighbors ('auto', 'ball_tree', 'kd_tree', 'brute')")
    leaf_size: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=30, description="Leaf size passed to BallTree or KDTree")
    p: Optional[Union[StrictFloat, StrictInt]] = Field(default=2, description="The power of the Minkowski metric to be used to calculate distance between points")
    n_jobs: Optional[StrictInt] = Field(default=1, description="The number of parallel jobs to run (-1 means using all processors)")
    __properties: ClassVar[List[str]] = ["eps", "min_samples", "metric", "metric_params", "algorithm", "leaf_size", "p", "n_jobs"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of DBSCANParams from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of DBSCANParams from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "eps": obj.get("eps") if obj.get("eps") is not None else 0.5,
            "min_samples": obj.get("min_samples") if obj.get("min_samples") is not None else 5,
            "metric": obj.get("metric") if obj.get("metric") is not None else 'euclidean',
            "metric_params": obj.get("metric_params"),
            "algorithm": obj.get("algorithm") if obj.get("algorithm") is not None else 'auto',
            "leaf_size": obj.get("leaf_size") if obj.get("leaf_size") is not None else 30,
            "p": obj.get("p") if obj.get("p") is not None else 2,
            "n_jobs": obj.get("n_jobs") if obj.get("n_jobs") is not None else 1
        })
        return _obj


