from typing import Self
import numpy as np
from collections.abc import MutableSequence
from classes.feature_vector import FeatureVector
from classes.concept import Concept

class Neuron:


    def __init__(self, weights: MutableSequence[float] = None) -> None:
        if weights is None:
            self.weights: np.ndarray = np.random.uniform(low=0, high=1, size=(106,))
        else:
            self.weights = np.asarray(weights, dtype=float)

    def classify(self, feature_vector: FeatureVector) -> int:
            
        x: list[float] = feature_vector.get_vector()
        x.append(1)  # adding bias

        
        multiplication = np.dot(x, self.weights)

        if (multiplication > 0):
            x.pop()
            return 1
        else:
            x.pop()
            return 0
            
    def add(self, sigma: float):
        self.weights = np.add(self.weights, sigma)

    def get_weights(self):
        return self.weights