Questions tagged [abc]

Abstract Base Classes are non-instantiable classes used to define the expected behaviour of subclasses.

280 questions
1
vote
1 answer

Constraints(Time/area..) in Yosys and/or ABC

I am using the following basic script to synthesize simple adder design # read design read_verilog fulladder1.v hierarchy -check # high-level synthesis proc; opt; fsm; opt; memory; opt # low-level synthesis techmap; opt # map to target…
1
vote
2 answers

How / Is it possible to have a vector>?

Revamping some old code where I was manually handling lifetimes of a vector of raw pointers to concrete instances of an abstract base class (ABC). So the vector's owner had a virtual dtor which manually went through and deleted the contents of the…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
1
vote
2 answers

How to incorporate type checking in an abstract base class in Python

When I define a class, I like to include type checking (using assert) of the input variables. I am now defining a 'specialized' class Rule which inherits from an abstract base class (ABC) BaseRule, similar to the following: import abc class…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
1
vote
0 answers

Standard interface for a class being an algebraic structure

Is there already any standard for an interface a Python class which is algebraic structure should implement? I want to make my code more generic. For example, numbers and square matrices are both semigroups with multiplication and one. If they…
abukaj
  • 2,582
  • 1
  • 22
  • 45
1
vote
2 answers

Factory class with abstractmethod

I've created a factory class called FitFunction that adds a whole bunch of stuff beyond what I've shown. The label method pretty_string is supposed to just return the string as written. When I run this file, it prints a string that is as useful as…
blalterman
  • 565
  • 7
  • 17
1
vote
1 answer

Do ABCs enforce method decorators?

I'm trying to figure out how to ensure that a method of a class inheriting from an ABC is created using the appropriate decorator. I understand (hopefully) how ABCs work in general. from abc import ABCMeta, abstractmethod class…
1
vote
1 answer

Inconsistent implementation of collections.abc

I'm trying to understand collections.abc source code. Let's take a look on Hashable class' __subclasshook__ implementation: @classmethod def __subclasshook__(cls, C): if cls is Hashable: for B in C.__mro__: if "__hash__" in…
mingaleg
  • 2,017
  • 16
  • 28
1
vote
2 answers

Can I define a constructor in an abstract base class?

I want to write an "interface" class in C++, which is a purely virtual abstract base class. Can I define the constructors in this interface class? A constructor cannot be a purely virtual function, but how can I then define constructors for the…
Fabian
  • 4,001
  • 4
  • 28
  • 59
1
vote
1 answer

computational cost of ABC

I have used abc in the past, and I'd like to use them again, to enforce pure virtual like methods with @abstractmethod. This is in the context of a Python front-end to an API which users will extend frequently. It's a bit too complicated for me to…
user349594
1
vote
1 answer

Using an abc.ABC class object in a Django template: why Django tries to instantiate it?

I want to use abc.ABC abstract class objects (not an instance) in a Django template. In these classes, I have several class methods (defined with the @classmethod decorator) that I'd like to use for displaying informations. When I try to show the…
Dim'
  • 518
  • 6
  • 12
1
vote
2 answers

Should I use an API/ABC when designing a class used by several in C++?

I am about to add a class X that will be used by my three previously designed classes (A, B and C). The new class X will contain data and functions for new features as well as provide services to the classes that use it to hide lower layers. The…
Tomas
  • 514
  • 1
  • 5
  • 15
1
vote
1 answer

How to implicitly use the base definition of a method

I'm currently developping for python 2, and I'm trying to use abstract base classes to simulate interfaces. I have an interface, a base implementation of that interface and many subclasses that extend the base implementation. It looks like…
Jazzwave06
  • 1,883
  • 1
  • 11
  • 19
1
vote
1 answer

Defining @property

I have problem in defining a getter by using @property in concrete class. Here is the python code: from abc import ABCMeta, abstractproperty class abstract(object): __metaclass__ = ABCMeta def __init__(self, value1): self.v1 =…
endeavour90
  • 87
  • 3
  • 7
1
vote
0 answers

building a python abc interface with a base class that derives from a built-in type

I would like to build an interface whose base class derives from a python built-in type such a dict. To do so, I use the python abc of the standard library but when I run the following test, no exception is raised for the missing method in the…
Eurydice
  • 8,001
  • 4
  • 24
  • 37
1
vote
1 answer

execute a terminal command using node.js

Iam trying to execute a terminal command using node.js spawn for that am using the code console.log(args) var child = spawn("hark", args, {cwd: workDir}); child.stdout.on('data', function(data) { console.log(data.toString()) …
Psl
  • 3,830
  • 16
  • 46
  • 84