#12876: Fix element and parent classes of Hom categories to be abstract, and
simplify the Hom logic.
-------------------------------------+--------------------------------------
       Reporter:  nthiery            |         Owner:  nthiery                  
     
           Type:  enhancement        |        Status:  needs_work               
     
       Priority:  major              |     Milestone:  sage-5.1                 
     
      Component:  categories         |    Resolution:                           
     
       Keywords:  categories, Hom    |   Work issues:  Fix ring_refcount_dict 
problem
Report Upstream:  N/A                |     Reviewers:  Simon King               
     
        Authors:  Nicolas M. ThiƩry  |     Merged in:                           
     
   Dependencies:  #12875, #12877     |      Stopgaps:                           
     
-------------------------------------+--------------------------------------

Comment (by SimonKing):

 Here is the rejection:
 {{{
 #!diff
 --- homset.py
 +++ homset.py
 @@ -165,43 +203,27 @@ def Hom(X, Y, category=None):
              if H.domain() is X and H.codomain() is Y:
                  return H

 -    try:
 -        return X._Hom_(Y, category)
 -    except (AttributeError, TypeError):
 -        pass
 -
      cat_X = X.category()
      cat_Y = Y.category()
      if category is None:
 -        category = cat_X._meet_(cat_Y)
 -    elif isinstance(category, Category):
 -        if not cat_X.is_subcategory(category):
 -            raise TypeError, "%s is not in %s"%(X, category)
 -        if not cat_Y.is_subcategory(category):
 -            raise TypeError, "%s is not in %s"%(Y, category)
 -    else:
 +        return Hom(X,Y,category=cat_X._meet_(cat_Y))
 +    if not isinstance(category, Category):
          raise TypeError, "Argument category (= %s) must be a
 category."%category
 -    # Now, as the category may have changed, we try to find the hom set
 in the cache, again:
 -    key = (X,Y,category)
 -    if _cache.has_key(key):
 -        H = _cache[key]()
 -        if H:
 -            # Are domain or codomain breaking the unique parent
 condition?
 -            if H.domain() is X and H.codomain() is Y:
 -                return H
 -
 -    # coercing would be incredibly annoying, since the domain and
 codomain
 -    # are totally different objects
 -    #X = category(X); Y = category(Y)
 +    if not cat_X.is_subcategory(category):
 +        raise TypeError, "%s is not in %s"%(X, category)
 +    if not cat_Y.is_subcategory(category):
 +        raise TypeError, "%s is not in %s"%(Y, category)

      # construct H
      # Design question: should the Homset classes get the category or the
 homset category?
      # For the moment, this is the category, for compatibility with the
 current implementations
      # of Homset in rings, schemes, ...
 -    H = category.hom_category().parent_class(X, Y, category = category)
 -
 -    ##_cache[key] = weakref.ref(H)
 -    _cache[(X, Y, category)] = weakref.ref(H)
 +    from sets_cat import Sets
 +    try:
 +        H = X._Hom_(Y, category)
 +    except (AttributeError, TypeError):
 +        H = Homset(X, Y, category = category)
 +    _cache[key] = weakref.ref(H)
      return H

  def hom(X, Y, f):
 }}}

 Why do you import Sets (new line 221)?

 Do I understand correctly: If Hom receives None as category, then you
 determine the category as the meet of the categories of domain and
 codomain, and call Hom again. Did you test that the calling overhead does
 not matter?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12876#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to