When I import cdb.core.component using
import cdb.core.component as comp
I get the following error:
File "/Users/hl/Library/Preferences/cadabra_packages/cdb/core/component.py", line 17, in <module>
from cdb.core._component import get_component
ModuleNotFoundError: No module named 'cdb.core._component'
When I go to the folder containing the file "component.py", I saw that there are 3 functions: "get_component", "remove_zero_components(ex), components_to_subrule(ex)" (this is expected as these are the 3 functions under the 'core.component' module), but the function "get_component" is grayed out (commented out). The code for this also has a strange import:
from cdb.core._component import get_component
which refers to "cdb.core._component" that cannot be found.
I recently updated Cadabra to the latest version and this is the first time I am using 'get_component' so I don't know what is wrong, but the fact that the entire 'get_component' function is grayed out is strange to me. I wish I could attach a screenshot to show this, but I can't find the option to attach an image (only the URL for the image), so I copied and pasted the code from "component.py" here:
import cadabra2
import imp
from cadabra2 import *
from cadabra2_defaults import *
__cdbkernel__ = cadabra2.__cdbkernel__
temp__all__ = dir() + ['temp__all__']
def display(ex):
pass
from cdb.utils.node import n_children
from cdb.core.manip import get_lhs, get_rhs
from cdb.utils.indices import get_free_indices
from cdb.core._component import get_component
#def get_component(ex, components):
# """Gets a particular component of an expression"""
# # Work on a copy of ex
# ex = ex.top().ex()
#
# # Replace all free indices with the components
# free_indices = get_free_indices(ex.top())
# if components.top().name != r"\comma":
# tmp = Ex(r'\comma')
# tmp.top().append_child(components.top())
# components = tmp
# assert len(free_indices) == n_children(components.top()), f"Expression contains {len(free_indices)} free indices, but {n_children(components.top())} components supplied"
# for index, component in zip(free_indices, components.top().children()):
# node = next(ex[index.top().name], None)
# changed = True
# while changed:
# for node in ex[index.top().name]:
# if node.parent_rel == parent_rel_t.super or node.parent_rel == parent_rel_t.sub:
# pr = node.parent_rel
# node.replace(component.ex())
# node.parent_rel = pr
# break
# else:
# changed = False
#
# # Replace all component nodes with the particular component we are looking for
# for node in ex[r'\components']:
# # Sift through \equals nodes finding the one with the right components
# for candidate in node[r'\equals']:
# arg = get_lhs(candidate)
# if arg == components:
# node = node.replace(get_rhs(candidate))
# break
# else:
# node = node.replace($0$)
#
# # The components paramater needs to have a head '\comma' node
# # so let's quickly make sure that's true.
# if components.head() != r'\comma':
# bit = $@(components)$
# components.top().name = r'\comma'
# components.top().append_child(bit)
#
# return ex
Thank you in advance for any help.