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
841
questions
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 ...
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 ...
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 ...
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 ...
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
...
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/...
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 # ...
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 ...
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, ...
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, ...
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
...
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() {
...
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 ...
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 ...
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 ...