Skip to content

util

get_implemented(f)

Prints the implemented methods of an operator

Parameters:

Name Type Description Default
f Callable

The operator to get the implemented methods of.

required

Returns:

Type Description

None

Source code in jaxdf/util.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def get_implemented(f):
  r"""Prints the implemented methods of an operator

    Arguments:
      f (Callable): The operator to get the implemented methods of.

    Returns:
      None

    """

  # TODO: Why there are more instances for the same types?

  print(f.__name__ + ":")
  instances = []
  a = f.methods
  for f_instance in a:
    # Get types
    types = f_instance.types

    # Change each type with its classname
    types = tuple(map(lambda x: x.__name__, types))

    # Append
    instances.append(str(types))

  instances = set(instances)
  for instance in instances:
    print(" ─ " + instance)

update_dictionary(old, new_entries)

Update a dictionary with new entries.

Parameters:

Name Type Description Default
old dict

The dictionary to update

required
new_entries dict

The new entries to add to the dictionary

required

Returns:

Name Type Description
dict

The updated dictionary

Source code in jaxdf/util.py
10
11
12
13
14
15
16
17
18
19
20
21
22
def update_dictionary(old: dict, new_entries: dict):
  r"""Update a dictionary with new entries.

    Args:
      old (dict): The dictionary to update
      new_entries (dict): The new entries to add to the dictionary

    Returns:
      dict: The updated dictionary
    """
  for key, val in zip(new_entries.keys(), new_entries.values()):
    old[key] = val
  return old