class_docstr: A simple implementation
  of a polynomial class that
  records the details about two polynomials
  that are potentially comprised of multiple
  variables.
class_docstr_tok: ["A","simple","implementation","of","a","polynomial","class","that","records","the","details","about","two","polynomials","that","are","potentially","comprised","of","multiple","variables","."]
docstr: Get the value after substituting
  certain values for the variables
  defined in substitutions.
docstr_tok: ["Get","the","value","after","substituting","certain","values","for","the","variables","defined","in","substitutions","."]
code: def subs(
      self,
      substitutions: Union[
          int, float, Fraction, Dict[int, Union[int, float, Fraction]]
      ],
  ) -> Union[int, float, Fraction]:
      """
      Get the value after substituting
      certain values for the variables
      defined in substitutions.
      """
      if (
          isinstance(substitutions, int)
          or isinstance(substitutions, float)
          or isinstance(substitutions, Fraction)
      ):
          substitutions = {
              i: Polynomial._rationalize_if_possible(substitutions)
              for i in set(self.variables())
          }
          return self.subs(substitutions)
      elif not isinstance(substitutions, dict):
          raise ValueError("The substitutions should be a dictionary.")
      if not self.variables().issubset(set(substitutions.keys())):
          raise ValueError(
              "Some variables didn't receive their values."
          )
  
      ans = 0
      for m in self.all_monomials():
          ans += Polynomial._rationalize_if_possible(
              m.substitute(substitutions)
          )
      return Polynomial._rationalize_if_possible(ans)
  
imports: from fractions import Fraction
  from typing import Dict, Union, Set, Iterable
  from numbers import Rational
  from functools import reduce
label_desc: Use image node_id 12 for calling the Polynomial obj's underlying member method code with example usage: obj.subs(substitutions) and returns: Polynomial, self