Coder Social home page Coder Social logo

Comments (8)

samet-akcay avatar samet-akcay commented on August 21, 2024 1

@onceone, The ABC inheritance ensures that this class cannot be instantiated directly if it has any abstract methods, but currently it doesn't have any. It is an indication that, AnomalibDataset is the base class, and cannot be used itself.

We could abstractmethod for the methods that we want to force subclasses to override specific methods.

In which part of the implementation do you think abstractmethod is missing?

from anomalib.

alexriedel1 avatar alexriedel1 commented on August 21, 2024

The methods in AnomalibDataset aren't very abstract buit very concrete actually. They aren't even implemented in most child classes, so abstract methods wouldn't make sense.

I don't know why the choice was made, to make AnomalibDataset an abstract base class. Maybe there was a time when the child classes needed to implement methods.

EDIT: ah @samet-akcay already gave the answer..

from anomalib.

onceone avatar onceone commented on August 21, 2024

Since there are no abstract methods, AnomalibDataset can be instantiated(as follows code), so why do we still need to inherit ABC?

from abc import ABC,abstractmethod
class Animal(ABC):

    # @abstractmethod
    def eat(self):
        print('eassst')

    @property
    def name(self):
        return 'Animal'
a = Animal()
a.eat()

from anomalib.

samet-akcay avatar samet-akcay commented on August 21, 2024

I don't exactly remember the main motivation, but I think we wanted to emphasise that AnomalibDataset cannot be used on its own yet since it is still missing __getitem__ method to be implemented.

@djdameln, can you comment on this?

from anomalib.

djdameln avatar djdameln commented on August 21, 2024

In previous versions of the library, AnomalibDataset had the abstract method _setup which had to be implemented in the subclasses to assign the samples dataframe. In v1.0.0 we stepped away from this design and assign the dataframe in the constructor. So you are right that it is technically no longer necessary to inherit from ABC. On the other hand, as @samet-akcay pointed out, the AnomalibDataset is not meant to be instantiated directly, and defining it as a base class could emphasise this.

from anomalib.

onceone avatar onceone commented on August 21, 2024

I think I got it . Thank you. By the way, do you have any recommendations for books on software design? Thanks again

from anomalib.

samet-akcay avatar samet-akcay commented on August 21, 2024

There are quite a bit of them, but I could list some here.

  • Design patterns : elements of reusable object-oriented software
  • Head First Design Patterns, 2E: Building Extensible and Maintainable Object-Oriented Software
  • Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems
  • Refactoring: Improving the Design of Existing Code

from anomalib.

onceone avatar onceone commented on August 21, 2024

Thanks

from anomalib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.