Open MuhammadUsamaSattar opened 4 months ago
Thanks for finding this! I can recreate this on master. Here's a simpler example
from pysindy import CustomLibrary, GeneralizedLibrary, PolynomialLibrary
import numpy as np
f_list = [lambda x: x]
lib_names_a = [lambda x: f'a({x})']
lib_names_b = [lambda x: f'b({x})']
lib_names_c = [lambda x: f'c({x})']
lib_a = CustomLibrary(f_list, lib_names_a)
lib_b = CustomLibrary(f_list, lib_names_b)
lib_c = CustomLibrary(f_list, lib_names_c)
inputs_per_library = [[1], [1], [0]]
tensor_array = [[1, 1, 1]]
feature_library = GeneralizedLibrary(
[lib_a, lib_b, lib_c],
tensor_array=tensor_array,
inputs_per_library=inputs_per_library,
)
feature_library.fit(np.array([[1, 2]])).get_feature_names(input_features = ["x", "y"])
Expected:
['a(y)', 'b(y)', 'c(x)', 'a(y) b(y) c(x)']
Actual:
['a(y)', 'b(y)', 'c(x)', 'a(y) b(y) c(y)']
And testing that the functions are applied as written:
feature_library.fit_transform(np.array([[1, 2]]))
Expected:
AxesArray([[ 2, 2, 1, 4]])
Actual
AxesArray([[ 2, 2, 1, 8]])
Hey! I am trying to fit a model for solenoids attracting pieces of ferromagnetic particles placed on water surface for nano/micro robotic manipulation. I have two custom libraries and one Polynomial library tensored together. Since no movement occurs without a current value, I believe, the current needs to be multiplied with each term (hence the Polynomial library). To achieve this, I am using the inputs_per_library argument for the Generalized Library. This gives the correct terms for combinations that consists of tensoring only two libraries, but for three libraries, the terms are incorrect.
Reproducing code example:
This gives me the following feature_names:
According to the set inputs_per_library, the last term in each term should be I/I^2/I^3 which is correct for all libraries generated by tensoring with only 2 libraries but for libraries generated with tensoring three libraries, 'r' is used instead of 'I'. You can see this issue for features from 'cos(theta) 1/r r' to 'cos(theta) 1/r^3 r^3'.
'cos(theta) 1/r^3 r^3' should be 'cos(theta) 1/r^3 I^3' instead, for example.