Skip to main content

Questions tagged [subclassing]

A subclass, "derived class", heir class, or child class is a modular, derivative class that inherits one or more language entities from one or more other classes.

subclassing
0 votes
0 answers
25 views

switching from subclassed model to functional api HOW

I was replicating a paper that has a complex model built in pytorch and wanted it in tensorflow for ease of use (I have been working for a while with tensorflow seems user friendly more for me please ...
ahmed mahmoud's user avatar
1 vote
1 answer
97 views

How does JavaScript "decide" how to print a class name?

I'm trying to write an inheritence logic where I clone an input class and inherit from remaining parent classes. In order to do that, I need to create a new class, deep copying one of the classes ...
ozgeneral's user avatar
  • 6,571
0 votes
0 answers
32 views

Is it possible to define a subclass in python that creates a new atomic attribute?

I'll call an "atomic" attribute of a python class to be one from which all other user defined attributes derive. For example, the attribute a in the class below is atomic to A because all ...
gdavtor's user avatar
  • 550
0 votes
0 answers
59 views

Adding a method to an existing enum in Python

I have an existing enumeration with a number of values defined in package b, and I want to add behavior in the current package a. I understand that you can't directly subclass an enum with existing ...
Paul's user avatar
  • 301
0 votes
0 answers
50 views

CMFCButton with transparent background

I have developed a class that subclasses from CMFCButton. I load three PNG images (with transparent zones) to the button foreground in the DrawButton function for three states: Normal Hovered Pushed ...
al072's user avatar
  • 89
1 vote
0 answers
32 views

Subclassing Pandas Series without losing original methods

I'm trying to implement my subclass of pd.Series, but original pd.Series methods don't work as expected and return Nan class Subclass(pd.Series): # see https://pandas.pydata.org/pandas-docs/stable/...
Mary.A's user avatar
  • 23
1 vote
2 answers
66 views

Is there a simple way to subclass python's set without redefining all operators?

Is there a way to subclass set, with the binary operator returning the subclassed type, without redefining them ? example : class A(set): pass a = A([1,2,3]) & A([1,2,4]) a.__class__ == A # ...
hl037_'s user avatar
  • 3,849
0 votes
0 answers
21 views

In Pyside2, when I subclass QSqlTableModel how do I write the data method without generating maximum recursion depth errors? [duplicate]

I have a working application in Pyside2 that displays a QSqlTableModel in a QSqlTableView. Three of the fields display raw seconds, like "6282" meaning six thousand and some seconds into a ...
Persistent at Python's user avatar
0 votes
0 answers
41 views

why the output of the tape.gradient is None? (Tensorflow)

EPOCHS = 10 LR = 0.001 loss_object = MeanSquaredError() optimizer = Adam(learning_rate = LR) load_metrics() @tf.function def trainer(): global train_ds, train_loss, model global optimizer, ...
LHB's user avatar
  • 11
0 votes
1 answer
62 views

Subclassing dict to give it inital values from a JSON file doesn't work as expected

I come from a C/C++ background I would like to subclass dict to make one that automatically opens a JSON file. Here's the code and problem: class DictFromJSON(dict): def get_from_file(self, ...
Kiwewi's user avatar
  • 1
0 votes
0 answers
21 views

How to change object attributes when overloading __getitem__ in np.ndarray subclassing

I have the following code: class myarray(np.ndarray): def __new__(cls, input_array): # Input array is an already formed ndarray instance # We first cast to be our class type ...
Jiadong's user avatar
  • 2,012
1 vote
1 answer
119 views

How to automatically forward class instance methods to another object's methods?

Regarding the following example code, is there any type-safe way of automatically forwarding any of the prototypal method calls, each to its related method of another object? class Foo { greet() { ...
Adam B.'s user avatar
  • 1,127
0 votes
0 answers
48 views

overwrite np.ndarray __getitem__

Target I'm dealing with 2D time-series data, and never use negative indexing. So I want to subclass np.ndarray that negative and out-of-bound indexing in axis 0 will return a nan-augmented matrix with ...
LeonM's user avatar
  • 45
3 votes
1 answer
53 views

Is an empty subclass of UIAlertController safe for use with `appearance(whenContainedInInstancesOf:)`

Somebody here on SO wanted to alter the behavior of UIAlertAction buttons in a specific UIAlertController, but not others. (They wanted multi-line button labels for one alert but normal behavior for ...
Duncan C's user avatar
  • 131k
0 votes
3 answers
459 views

How to dynamically create a subclass from a given class and enhance/augment the subclass constructor's prototype?

I have an unusual situation where I need to dynamically generate a class prototype then have a reflection tool (which can't be changed) walk the prototype and find all the methods. If I could hard ...
DoomGoober's user avatar
  • 1,663

15 30 50 per page
1
2 3 4 5
57