@@ -180,11 +180,11 @@ static PyObject* CallPythonFuncOnOneArg(PyObject* function, PyObject* single_arg
180180#ifndef NMZ_RELEASE
181181static_assert (
182182 false ,
183- " Your Normaliz version (unknown) is too old! Update to 3.10.2 or newer." );
183+ " Your Normaliz version (unknown) is too old! Update to 3.10.3 or newer." );
184184#endif
185- #if NMZ_RELEASE < 31000
185+ #if NMZ_RELEASE < 31003
186186static_assert (false ,
187- " Your Normaliz version is too old! Update to 3.10.2 or newer." );
187+ " Your Normaliz version is too old! Update to 3.10.3 or newer." );
188188#endif
189189
190190/* **************************************************************************
@@ -713,6 +713,27 @@ NmzFacelatticeToPython(const map<dynamic_bitset, int>& lattice)
713713 return list;
714714}
715715
716+ static PyObject*
717+ NmzModularGradingsToPython (const vector<vector<dynamic_bitset> >& gradings)
718+ {
719+ ssize_t nr_gradings = gradings.size ();
720+ PyObject* grad_list = PyList_New (nr_gradings);
721+ if (nr_gradings == 0 )
722+ return grad_list;
723+ size_t curr = 0 ;
724+ for (auto & this_grad: gradings){
725+ PyObject* list_part = PyList_New (this_grad.size ());
726+ size_t inner_curr = 0 ;
727+ for (auto & part: this_grad){
728+ PyList_SetItem (list_part, inner_curr, NmzToPyNumber (part));
729+ inner_curr++;
730+ }
731+ PyList_SetItem (grad_list, curr, list_part);
732+ curr++;
733+ }
734+ return grad_list;
735+ }
736+
716737template < typename Integer >
717738static PyObject*
718739NmzAutomorphismsToPython (const AutomorphismGroup< Integer >& grp)
@@ -1881,6 +1902,9 @@ _NmzResultImpl(Cone< Integer >* C, PyObject* prop_obj, const void* nf = nullptr)
18811902 case libnormaliz::ConeProperty::Incidence:
18821903 return NmzVectorToPyList (C->getIncidence ());
18831904
1905+ case libnormaliz::ConeProperty::ModularGradings:
1906+ return NmzModularGradingsToPython (C->getModularGradings ());
1907+
18841908 default : {
18851909 switch (outputtype) {
18861910 case libnormaliz::OutputType::Matrix:
@@ -2295,7 +2319,7 @@ static PyObject* NmzSetPolynomialInequalities(PyObject* self, PyObject* args)
22952319
22962320/* **************************************************************************
22972321 *
2298- * FaceCodimBound
2322+ * FaceCodimBound and other numerical parameters
22992323 *
23002324 ***************************************************************************/
23012325
@@ -2338,6 +2362,45 @@ static PyObject* NmzSetFaceCodimBound(PyObject* self, PyObject* args)
23382362 FUNC_END
23392363}
23402364
2365+ static PyObject* NmzSetModularGrading (PyObject* self, PyObject* args)
2366+ {
2367+
2368+ FUNC_BEGIN
2369+
2370+ PyObject* cone = PyTuple_GetItem (args, 0 );
2371+
2372+ if (!is_cone (cone)) {
2373+ PyErr_SetString (PyNormaliz_cppError, " First argument must be a cone" );
2374+ return NULL ;
2375+ }
2376+
2377+ PyObject* mod_gr_py = PyTuple_GetItem (args, 1 );
2378+
2379+ TempSignalHandler tmpHandler; // use custom signal handler
2380+
2381+ int overflow;
2382+ long mod_gr = PyLong_AsLongLongAndOverflow (mod_gr_py, &overflow);
2383+ if (is_cone_mpz (cone)) {
2384+ Cone< mpz_class >* cone_ptr = get_cone_mpz (cone);
2385+ cone_ptr->setModularGraing (mod_gr);
2386+ Py_RETURN_TRUE;
2387+ }
2388+ else if (is_cone_long (cone)) {
2389+ Cone< long long >* cone_ptr = get_cone_long (cone);
2390+ cone_ptr->setModularGraing (mod_gr);
2391+ Py_RETURN_TRUE;
2392+ }
2393+ #ifdef ENFNORMALIZ
2394+ else {
2395+ Cone<renf_elem_class>* cone_ptr = get_cone_renf (cone);
2396+ cone_ptr->setModularGraing (mod_gr);
2397+ Py_RETURN_TRUE;
2398+ }
2399+ #endif
2400+
2401+ FUNC_END
2402+ }
2403+
23412404static PyObject* NmzSetGBDegreeBound (PyObject* self, PyObject* args)
23422405{
23432406
@@ -2402,6 +2465,7 @@ static PyObject* NmzSetGBMinDegree(PyObject* self, PyObject* args)
24022465 else if (is_cone_long (cone)) {
24032466 Cone< long long >* cone_ptr = get_cone_long (cone);
24042467 cone_ptr->setGBMinDegree (bound);
2468+ Py_RETURN_TRUE;
24052469 }
24062470#ifdef ENFNORMALIZ
24072471 else {
@@ -2942,6 +3006,8 @@ static PyMethodDef PyNormaliz_cppMethods[] = {
29423006 METH_VARARGS, " Sets the polynomial inequalities for lattice points" },
29433007 {" NmzSetFaceCodimBound" , (PyCFunction)NmzSetFaceCodimBound,
29443008 METH_VARARGS, " Sets the maximal codimension for the computed faces" },
3009+ {" NmzSetModularGrading" , (PyCFunction)NmzSetModularGrading,
3010+ METH_VARARGS, " Picks a modular grading (counting from 1)" },
29453011 {" NmzSetGBDegreeBound" , (PyCFunction)NmzSetGBDegreeBound,
29463012 METH_VARARGS, " Sets the maximal degree for binomials in Gröbner and Markov bases" },
29473013 {" NmzSetGBMinDegree" , (PyCFunction)NmzSetGBMinDegree,
0 commit comments