@@ -950,7 +950,7 @@ cdef class flint_mpoly(flint_elem):
950950 )
951951 return new_ctx, self .coerce_to_context(new_ctx)
952952
953- def coerce_to_context (self , ctx , mapping: dict[str | int , str | int] = None ):
953+ def coerce_to_context (self , other_ctx , mapping: dict[str | int , str | int] = None ):
954954 """
955955 Coerce this polynomial to a different context.
956956
@@ -975,23 +975,24 @@ cdef class flint_mpoly(flint_elem):
975975 slong * c_mapping
976976 slong i
977977
978- if not typecheck(ctx, type (self .ctx)):
978+ ctx = self .context()
979+ if not typecheck(other_ctx, type (ctx)):
979980 raise ValueError (
980- f" provided context is not a {self. ctx.__class__.__name__}"
981+ f" provided context is not a {ctx.__class__.__name__}"
981982 )
982- elif self . ctx is ctx :
983+ elif ctx is other_ctx :
983984 return self
984985
985986 if mapping is None :
986- mapping = self . ctx.infer_generator_mapping(ctx )
987+ mapping = ctx.infer_generator_mapping(other_ctx )
987988 else :
988989 mapping = {
989- self . ctx.variable_to_index(k): ctx.variable_to_index(v)
990+ ctx.variable_to_index(k): ctx.variable_to_index(v)
990991 for k, v in mapping.items()
991992 }
992993
993994 try :
994- c_mapping = < slong * > libc.stdlib.malloc(self . ctx.nvars() * sizeof(slong * ))
995+ c_mapping = < slong * > libc.stdlib.malloc(ctx.nvars() * sizeof(slong * ))
995996 if c_mapping is NULL :
996997 raise MemoryError (" malloc returned a null pointer" )
997998
@@ -1001,11 +1002,11 @@ cdef class flint_mpoly(flint_elem):
10011002 for k, v in mapping.items():
10021003 c_mapping[k] = < slong> v
10031004
1004- return self ._compose_gens_(ctx , c_mapping)
1005+ return self ._compose_gens_(other_ctx , c_mapping)
10051006 finally :
10061007 libc.stdlib.free(c_mapping)
10071008
1008- cdef _compose_gens_(self , ctx , slong * mapping):
1009+ cdef _compose_gens_(self , other_ctx , slong * mapping):
10091010 raise NotImplementedError (" abstract method" )
10101011
10111012
0 commit comments