code: def new_space(
          self,
          name=None,
          bases=None,
          formula=None,
          *,
          refs=None,
          source=None,
          is_derived=False,
          prefix=""
      ):
          
          from modelx.core.space import StaticSpaceImpl
  
          if name is None:
              name = self.spacenamer.get_next(self.namespace, prefix)
  
          if name in self.namespace:
              raise ValueError("Name '%s' already exists." % name)
  
          if not prefix and not is_valid_name(name):
              raise ValueError("Invalid name '%s'." % name)
  
          space = self._new_space(
              name=name,
              formula=formula,
              refs=refs,
              source=source,
              is_derived=is_derived,
          )
          self._set_space(space)
  
          self.model.spacegraph.add_space(space)
  
          # Set up direct base spaces and mro
          if bases is not None:
              if isinstance(bases, StaticSpaceImpl):
                  bases = [bases]
  
              space.add_bases(bases)
  
          return space
docs: Create a new child space.
  
          Args:
              name (str): Name of the space. If omitted, the space is
                  created automatically.
              bases: If specified, the new space becomes a derived space of
                  the `base` space.
              formula: Function whose parameters used to set space parameters.
              refs: a mapping of refs to be added.
              arguments: ordered dict of space parameter names to their values.
              source: A source module from which cell definitions are read.
              prefix: Prefix to the autogenerated name when name is None.