From d11689ecc6d76b21154a4bbcc36344744d3e4d5c Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Thu, 15 Feb 2024 08:41:15 +0100 Subject: [PATCH] Rename make_cfunc() -> cfunc(). --- doc/notebooks/NeuralODEs.ipynb | 2 +- ...trol of the Lotka-Volterra equations.ipynb | 2 +- doc/notebooks/Outer Solar System.ipynb | 2 +- .../Periodic orbits in the CR3BP.ipynb | 4 +- ...arc-length continuation in the CR3BP.ipynb | 4 +- doc/notebooks/arbitrary_precision.ipynb | 2 +- doc/notebooks/compiled_functions.ipynb | 18 +++--- doc/notebooks/computing_derivatives.ipynb | 6 +- doc/notebooks/elp2000.ipynb | 2 +- doc/notebooks/ex_system_revisited.ipynb | 8 +-- doc/notebooks/ffnn.ipynb | 4 +- doc/notebooks/lagrangian_propagator.ipynb | 4 +- doc/notebooks/projection.ipynb | 6 +- doc/notebooks/single_precision.ipynb | 2 +- doc/notebooks/torch_and_heyoka.ipynb | 2 +- doc/notebooks/vsop2013.ipynb | 2 +- heyoka/__init__.py | 2 +- heyoka/_test_cfunc.py | 58 +++++++++---------- heyoka/_test_elp2000.py | 6 +- heyoka/_test_mp.py | 8 +-- heyoka/_test_vsop2013.py | 6 +- 21 files changed, 75 insertions(+), 75 deletions(-) diff --git a/doc/notebooks/NeuralODEs.ipynb b/doc/notebooks/NeuralODEs.ipynb index 975a9880..8c513a42 100644 --- a/doc/notebooks/NeuralODEs.ipynb +++ b/doc/notebooks/NeuralODEs.ipynb @@ -416,7 +416,7 @@ "outputs": [], "source": [ "# Assemble the r.h.s. for scipy-integration\n", - "rhs = hy.make_cfunc(fn = [it[1] for it in dyn], compact_mode=True, vars = state + list(phi.flatten())+ list(varphi.flatten()))" + "rhs = hy.cfunc(fn = [it[1] for it in dyn], compact_mode=True, vars = state + list(phi.flatten())+ list(varphi.flatten()))" ] }, { diff --git a/doc/notebooks/Optimal Control of the Lotka-Volterra equations.ipynb b/doc/notebooks/Optimal Control of the Lotka-Volterra equations.ipynb index 260efa73..9c5079cc 100644 --- a/doc/notebooks/Optimal Control of the Lotka-Volterra equations.ipynb +++ b/doc/notebooks/Optimal Control of the Lotka-Volterra equations.ipynb @@ -196,7 +196,7 @@ "\n", "# Introduce a compiled function\n", "# for the evaluation of the Hamiltonian.\n", - "H_cf = hy.make_cfunc([H], vars=[x, y, lx, ly, u])\n", + "H_cf = hy.cfunc([H], vars=[x, y, lx, ly, u])\n", "\n", "def _hamiltonian(x,y,lx,ly,p):\n", " sw_v = switching_function(x,y,lx,ly,p)\n", diff --git a/doc/notebooks/Outer Solar System.ipynb b/doc/notebooks/Outer Solar System.ipynb index e9a1cef7..f8cd88e6 100644 --- a/doc/notebooks/Outer Solar System.ipynb +++ b/doc/notebooks/Outer Solar System.ipynb @@ -141,7 +141,7 @@ "metadata": {}, "outputs": [], "source": [ - "en_cf = hy.make_cfunc([hy.model.nbody_energy(6, masses = masses, Gconst = G)],\n", + "en_cf = hy.cfunc([hy.model.nbody_energy(6, masses = masses, Gconst = G)],\n", " # NOTE: the variables for the compiled function\n", " # are taken from the definition of the ODE system.\n", " vars=[_[0] for _ in sys])" diff --git a/doc/notebooks/Periodic orbits in the CR3BP.ipynb b/doc/notebooks/Periodic orbits in the CR3BP.ipynb index 30b08b35..72728760 100644 --- a/doc/notebooks/Periodic orbits in the CR3BP.ipynb +++ b/doc/notebooks/Periodic orbits in the CR3BP.ipynb @@ -162,7 +162,7 @@ "source": [ "# Introduce a compiled function for the evaluation\n", "# of the dynamics equation for px.\n", - "px_dyn_cf = hy.make_cfunc([f[3]], vars=x)\n", + "px_dyn_cf = hy.cfunc([f[3]], vars=x)\n", "\n", "def compute_L_points(mu):\n", " \"\"\"Computes The exact position of the Lagrangian points. To do so it finds the zeros of the\n", @@ -651,7 +651,7 @@ "source": [ "# Introduce a compiled function for the evaluation\n", "# of the dynamics equations.\n", - "dyn_cf = hy.make_cfunc(f, vars=x)\n", + "dyn_cf = hy.cfunc(f, vars=x)\n", "\n", "def corrector(ta, x0):\n", " \"\"\"\n", diff --git a/doc/notebooks/Pseudo arc-length continuation in the CR3BP.ipynb b/doc/notebooks/Pseudo arc-length continuation in the CR3BP.ipynb index caec005e..b5f48cc7 100644 --- a/doc/notebooks/Pseudo arc-length continuation in the CR3BP.ipynb +++ b/doc/notebooks/Pseudo arc-length continuation in the CR3BP.ipynb @@ -153,8 +153,8 @@ "f = np.array(f)\n", "\n", "# We compile the r.h.s. of the dynamics into compiled functions as to later be able to evaluate their numerical values magnitude.\n", - "cf_f = hy.make_cfunc(f, vars=x)\n", - "cf_px = hy.make_cfunc([f[3]], vars=[x[0],x[1],x[2],x[4]]) # x,y,z,py" + "cf_f = hy.cfunc(f, vars=x)\n", + "cf_px = hy.cfunc([f[3]], vars=[x[0],x[1],x[2],x[4]]) # x,y,z,py" ] }, { diff --git a/doc/notebooks/arbitrary_precision.ipynb b/doc/notebooks/arbitrary_precision.ipynb index 5017061a..4f66e52c 100644 --- a/doc/notebooks/arbitrary_precision.ipynb +++ b/doc/notebooks/arbitrary_precision.ipynb @@ -634,7 +634,7 @@ "sym_func = x**2-y**2\n", "\n", "# Compile it.\n", - "cf = hy.make_cfunc([sym_func], [x, y],\n", + "cf = hy.cfunc([sym_func], [x, y],\n", " fp_type=real, prec=prec)" ] }, diff --git a/doc/notebooks/compiled_functions.ipynb b/doc/notebooks/compiled_functions.ipynb index 3f20fcdc..b46392f3 100644 --- a/doc/notebooks/compiled_functions.ipynb +++ b/doc/notebooks/compiled_functions.ipynb @@ -57,7 +57,7 @@ "id": "68861247-8ac9-42a3-bf58-b893282ccdf7", "metadata": {}, "source": [ - "We can now proceed to JIT compile ``sym_func`` via the ``make_cfunc()`` function. ``make_cfunc()`` takes two mandatory input arguments:\n", + "We can now proceed to JIT compile ``sym_func`` via the ``cfunc()`` function. ``cfunc()`` takes two mandatory input arguments:\n", "\n", "- the list of symbolic expressions representing the outputs of the vector function, and\n", "- the list of symbolic variables representing the inputs of the function.\n", @@ -72,7 +72,7 @@ "metadata": {}, "outputs": [], "source": [ - "cf = hy.make_cfunc([sym_func], [x, y])" + "cf = hy.cfunc([sym_func], [x, y])" ] }, { @@ -80,7 +80,7 @@ "id": "8df3f92c-49b2-459d-bb0a-33e2e000812c", "metadata": {}, "source": [ - "The value returned by ``make_cfunc()`` is a callable function object which accepts as input a NumPy array representing the values to use in the evaluation of ``sym_func``:" + "The value returned by ``cfunc()`` is a callable function object which accepts as input a NumPy array representing the values to use in the evaluation of ``sym_func``:" ] }, { @@ -163,7 +163,7 @@ } ], "source": [ - "cf2 = hy.make_cfunc([sym_func], vars=[y,x])\n", + "cf2 = hy.cfunc([sym_func], vars=[y,x])\n", "\n", "# Evaluate for x=1 and y=5.\n", "cf2([5,1])" @@ -205,9 +205,9 @@ "id": "43f895e7-2da5-440d-84f8-1932d5a9d1fc", "metadata": {}, "source": [ - "``make_cfunc()`` accepts several additional keyword arguments, the most important of which is the boolean flag ``compact_mode`` (defaulting to ``False``). Similarly to the [adaptive Taylor integrators](<./Customising the adaptive integrator.ipynb>), you should enable ``compact_mode`` if you want to compile extremely large symbolic expressions that result in excessively long compilation times. The downside of ``compact_mode`` is a slight performance degradation due to the different code generation model adopted during the JIT compilation process.\n", + "``cfunc()`` accepts several additional keyword arguments, the most important of which is the boolean flag ``compact_mode`` (defaulting to ``False``). Similarly to the [adaptive Taylor integrators](<./Customising the adaptive integrator.ipynb>), you should enable ``compact_mode`` if you want to compile extremely large symbolic expressions that result in excessively long compilation times. The downside of ``compact_mode`` is a slight performance degradation due to the different code generation model adopted during the JIT compilation process.\n", "\n", - "The function object returned by ``make_cfunc()`` also accepts several optional keyword arguments. It is possible, for instance, to pass as ``outputs`` argument a pre-allocated NumPy array into which the result of the evaluation will be written. This is useful to avoid the overhead of allocating new memory for the return value, if such memory is already available:" + "The function object returned by ``cfunc()`` also accepts several optional keyword arguments. It is possible, for instance, to pass as ``outputs`` argument a pre-allocated NumPy array into which the result of the evaluation will be written. This is useful to avoid the overhead of allocating new memory for the return value, if such memory is already available:" ] }, { @@ -273,7 +273,7 @@ "sym_func_par = hy.par[0]*x**2-hy.par[1]*y**2+hy.par[2]\n", "\n", "# Compile it.\n", - "cf_par = hy.make_cfunc([sym_func_par], [x, y])\n", + "cf_par = hy.cfunc([sym_func_par], [x, y])\n", "\n", "# Evaluate, specifying the parameter values\n", "cf_par([1,5], pars=[-1, -2, -3])" @@ -315,7 +315,7 @@ "sym_func_tm = x**2-y**2+hy.time\n", "\n", "# Compile it.\n", - "cf_tm = hy.make_cfunc([sym_func_tm], [x, y])\n", + "cf_tm = hy.cfunc([sym_func_tm], [x, y])\n", "\n", "# Evaluate for x=1, y=5 and time=6.\n", "cf_tm([1,5], time=6)" @@ -538,7 +538,7 @@ "metadata": {}, "outputs": [], "source": [ - "Ham_cf = hy.make_cfunc([Ham_sym], vars=[px,py,pz,x,y,z])" + "Ham_cf = hy.cfunc([Ham_sym], vars=[px,py,pz,x,y,z])" ] }, { diff --git a/doc/notebooks/computing_derivatives.ipynb b/doc/notebooks/computing_derivatives.ipynb index 56ca20bb..746a067a 100644 --- a/doc/notebooks/computing_derivatives.ipynb +++ b/doc/notebooks/computing_derivatives.ipynb @@ -495,7 +495,7 @@ } ], "source": [ - "grad_diff_cf = hy.make_cfunc(grad_diff, sym_vars)\n", + "grad_diff_cf = hy.cfunc(grad_diff, sym_vars)\n", "grad_diff_cf.decomposition[8:-8]" ] }, @@ -582,7 +582,7 @@ } ], "source": [ - "grad_diff_tensors_cf = hy.make_cfunc(grad_diff_tensors, sym_vars)\n", + "grad_diff_tensors_cf = hy.cfunc(grad_diff_tensors, sym_vars)\n", "grad_diff_tensors_cf.decomposition[8:-8]" ] }, @@ -621,7 +621,7 @@ " grad_diff_tensors = [t[1] for t in hy.diff_tensors([sp_func],\n", " diff_args=hy.diff_args.vars,\n", " diff_order=1).get_derivatives(1)]\n", - " grad_diff_tensors_cf = hy.make_cfunc(grad_diff_tensors, sym_vars)\n", + " grad_diff_tensors_cf = hy.cfunc(grad_diff_tensors, sym_vars)\n", " nops.append(len(grad_diff_tensors_cf.decomposition) - 2*nvars)\n", "\n", "%matplotlib inline\n", diff --git a/doc/notebooks/elp2000.ipynb b/doc/notebooks/elp2000.ipynb index 246616f4..bee370df 100644 --- a/doc/notebooks/elp2000.ipynb +++ b/doc/notebooks/elp2000.ipynb @@ -230,7 +230,7 @@ " thresh=thr)\n", "\n", " # Compile the function for the evaluation of moon_x/y/z.\n", - " moon_cf = hy.make_cfunc([moon_x, moon_y, moon_z], [tm], compact_mode=True)\n", + " moon_cf = hy.cfunc([moon_x, moon_y, moon_z], [tm], compact_mode=True)\n", " \n", " # Run the evaluation.\n", " elp2000_states = moon_cf(dates.reshape((1,-1)))\n", diff --git a/doc/notebooks/ex_system_revisited.ipynb b/doc/notebooks/ex_system_revisited.ipynb index 7f6e3db4..591594ed 100644 --- a/doc/notebooks/ex_system_revisited.ipynb +++ b/doc/notebooks/ex_system_revisited.ipynb @@ -499,7 +499,7 @@ "metadata": {}, "outputs": [], "source": [ - "f_cf = hy.make_cfunc([x+y+1., x+y+z], [x, y, z])" + "f_cf = hy.cfunc([x+y+1., x+y+z], [x, y, z])" ] }, { @@ -608,7 +608,7 @@ "metadata": {}, "outputs": [], "source": [ - "f_cf_fix = hy.make_cfunc([hy.fix(x+y)+1., hy.fix(x+y)+z],\n", + "f_cf_fix = hy.cfunc([hy.fix(x+y)+1., hy.fix(x+y)+z],\n", " [x, y, z])" ] }, @@ -711,7 +711,7 @@ } ], "source": [ - "g_cf = hy.make_cfunc([2.0 * (x + y + z)], [x, y, z])\n", + "g_cf = hy.cfunc([2.0 * (x + y + z)], [x, y, z])\n", "g_cf.decomposition" ] }, @@ -741,7 +741,7 @@ } ], "source": [ - "g_cf_fix = hy.make_cfunc([2.0 * hy.fix(x + y + z)],\n", + "g_cf_fix = hy.cfunc([2.0 * hy.fix(x + y + z)],\n", " [x, y, z])\n", "g_cf_fix.decomposition" ] diff --git a/doc/notebooks/ffnn.ipynb b/doc/notebooks/ffnn.ipynb index dc03aebf..4c86fd2b 100644 --- a/doc/notebooks/ffnn.ipynb +++ b/doc/notebooks/ffnn.ipynb @@ -170,7 +170,7 @@ } ], "source": [ - "cf = hy.make_cfunc(ffnn, [x, y])\n", + "cf = hy.cfunc(ffnn, [x, y])\n", "print(cf)" ] }, @@ -251,7 +251,7 @@ } ], "source": [ - "cf = hy.make_cfunc(ffnn, [x, y])\n", + "cf = hy.cfunc(ffnn, [x, y])\n", "print(cf)" ] }, diff --git a/doc/notebooks/lagrangian_propagator.ipynb b/doc/notebooks/lagrangian_propagator.ipynb index a297f419..74e89ad6 100644 --- a/doc/notebooks/lagrangian_propagator.ipynb +++ b/doc/notebooks/lagrangian_propagator.ipynb @@ -214,7 +214,7 @@ "metadata": {}, "outputs": [], "source": [ - "cf = hy.make_cfunc(pos_vel,\n", + "cf = hy.cfunc(pos_vel,\n", " # Specify the order in which the input\n", " # variables are passed to the compiled\n", " # function.\n", @@ -373,7 +373,7 @@ "metadata": {}, "outputs": [], "source": [ - "cf_stm = hy.make_cfunc(jac.flatten(),\n", + "cf_stm = hy.cfunc(jac.flatten(),\n", " # Specify the order in which the input\n", " # variables are passed to the compiled\n", " # function.\n", diff --git a/doc/notebooks/projection.ipynb b/doc/notebooks/projection.ipynb index 49f8e0e8..8f960c9c 100644 --- a/doc/notebooks/projection.ipynb +++ b/doc/notebooks/projection.ipynb @@ -113,7 +113,7 @@ "source": [ "# Define a compiled function for the computation\n", "# of the energy in an N-body system from its state vector.\n", - "en_cfunc = hy.make_cfunc([hy.model.nbody_energy(6, masses=masses, Gconst=G)],\n", + "en_cfunc = hy.cfunc([hy.model.nbody_energy(6, masses=masses, Gconst=G)],\n", " vars=state_vars)" ] }, @@ -511,7 +511,7 @@ "metadata": {}, "outputs": [], "source": [ - "objfun_cfunc = hy.make_cfunc([dist2_ex] + grad_dist2_ex, vars=state_vars)" + "objfun_cfunc = hy.cfunc([dist2_ex] + grad_dist2_ex, vars=state_vars)" ] }, { @@ -561,7 +561,7 @@ "\n", "# The compiled function for the computation of the gradient\n", "# of the constraint.\n", - "grad_cstr_cfunc = hy.make_cfunc(grad_cstr, vars=state_vars)" + "grad_cstr_cfunc = hy.cfunc(grad_cstr, vars=state_vars)" ] }, { diff --git a/doc/notebooks/single_precision.ipynb b/doc/notebooks/single_precision.ipynb index 4af82b60..439686ab 100644 --- a/doc/notebooks/single_precision.ipynb +++ b/doc/notebooks/single_precision.ipynb @@ -113,7 +113,7 @@ "source": [ "x, v = hy.make_vars(\"x\", \"v\")\n", "\n", - "cf_en = hy.make_cfunc([en], fp_type=np.single,\n", + "cf_en = hy.cfunc([en], fp_type=np.single,\n", " vars=[x, v])" ] }, diff --git a/doc/notebooks/torch_and_heyoka.ipynb b/doc/notebooks/torch_and_heyoka.ipynb index 6a4f4fa6..9d687844 100644 --- a/doc/notebooks/torch_and_heyoka.ipynb +++ b/doc/notebooks/torch_and_heyoka.ipynb @@ -181,7 +181,7 @@ "metadata": {}, "outputs": [], "source": [ - "model_heyoka_compiled=hk.make_cfunc(model_heyoka, [inp_1, inp_2, inp_3, inp_4])" + "model_heyoka_compiled=hk.cfunc(model_heyoka, [inp_1, inp_2, inp_3, inp_4])" ] }, { diff --git a/doc/notebooks/vsop2013.ipynb b/doc/notebooks/vsop2013.ipynb index 0c972b3b..1bcb66ca 100644 --- a/doc/notebooks/vsop2013.ipynb +++ b/doc/notebooks/vsop2013.ipynb @@ -248,7 +248,7 @@ " thresh=thr)[:3]\n", "\n", " # Compile the function for the evaluation of venus_x/y/z.\n", - " venus_cf = hy.make_cfunc([venus_x, venus_y, venus_z], [tm], compact_mode=True)\n", + " venus_cf = hy.cfunc([venus_x, venus_y, venus_z], [tm], compact_mode=True)\n", " \n", " # Run the evaluation.\n", " vsop_states = venus_cf(dates.reshape((1,-1)))\n", diff --git a/heyoka/__init__.py b/heyoka/__init__.py index 02ad55a5..fa79e781 100644 --- a/heyoka/__init__.py +++ b/heyoka/__init__.py @@ -138,7 +138,7 @@ def taylor_add_jet(sys, order, **kwargs): return getattr(core, "_taylor_add_jet{}".format(fp_suffix))(sys, order, **kwargs) -def make_cfunc(fn, vars, **kwargs): +def cfunc(fn, vars, **kwargs): from . import core fp_type = kwargs.pop("fp_type", float) diff --git a/heyoka/_test_cfunc.py b/heyoka/_test_cfunc.py index f25035f3..17f7f412 100644 --- a/heyoka/_test_cfunc.py +++ b/heyoka/_test_cfunc.py @@ -12,11 +12,11 @@ class cfunc_test_case(_ut.TestCase): def test_basic(self): - from . import make_cfunc, make_vars, cfunc_dbl, core, par, time + from . import cfunc, make_vars, cfunc_dbl, core, par, time import pickle from copy import copy, deepcopy - self.assertRaises(ValueError, lambda: make_cfunc([], [])) + self.assertRaises(ValueError, lambda: cfunc([], [])) def_cted = cfunc_dbl() @@ -35,7 +35,7 @@ def test_basic(self): ) x, y, z, s = make_vars("x", "y", "z", "s") - cf = make_cfunc([y * (x + z)], [x, y, z]) + cf = cfunc([y * (x + z)], [x, y, z]) self.assertFalse(cf.llvm_state_scalar.force_avx512) self.assertFalse(cf.llvm_state_scalar.slp_vectorize) @@ -79,7 +79,7 @@ def test_basic(self): cf.llvm_state_batch.get_ir(), ) - cf = make_cfunc( + cf = cfunc( [y * (x + z)], vars=[y, z, x], force_avx512=True, slp_vectorize=True ) self.assertEqual(cf.list_var, [y, z, x]) @@ -92,27 +92,27 @@ def test_basic(self): # Tests for correct detection of number of params, time dependency # and list of variables. - cf = make_cfunc([y * (x + z), x], vars=[y, z, x]) + cf = cfunc([y * (x + z), x], vars=[y, z, x]) self.assertEqual(cf.param_size, 0) - cf = make_cfunc([y * (x + z), par[0]], vars=[y, z, x]) + cf = cfunc([y * (x + z), par[0]], vars=[y, z, x]) self.assertEqual(cf.param_size, 1) - cf = make_cfunc([y * (x + z) - par[89], par[0]], vars=[y, z, x]) + cf = cfunc([y * (x + z) - par[89], par[0]], vars=[y, z, x]) self.assertEqual(cf.param_size, 90) - cf = make_cfunc([y * (x + z), x], vars=[y, z, x]) + cf = cfunc([y * (x + z), x], vars=[y, z, x]) self.assertFalse(cf.is_time_dependent) - cf = make_cfunc([y * (x + z) + time, x], vars=[y, z, x]) + cf = cfunc([y * (x + z) + time, x], vars=[y, z, x]) self.assertTrue(cf.is_time_dependent) - cf = make_cfunc([y * (x + z), x + time], vars=[y, z, x]) + cf = cfunc([y * (x + z), x + time], vars=[y, z, x]) self.assertTrue(cf.is_time_dependent) - cf = make_cfunc([y * (x + z), x + time], [x, y, z]) + cf = cfunc([y * (x + z), x + time], [x, y, z]) self.assertEqual(cf.list_var, [x, y, z]) - cf = make_cfunc([y * (x + z), x + time], vars=[y, z, x]) + cf = cfunc([y * (x + z), x + time], vars=[y, z, x]) self.assertEqual(cf.list_var, [y, z, x]) - cf = make_cfunc([y * (x + z), x + time], vars=[y, z, x, s]) + cf = cfunc([y * (x + z), x + time], vars=[y, z, x, s]) self.assertEqual(cf.list_var, [y, z, x, s]) - cf = make_cfunc([y * (x + z), x + time], vars=[s, y, z, x]) + cf = cfunc([y * (x + z), x + time], vars=[s, y, z, x]) self.assertEqual(cf.list_var, [s, y, z, x]) # NOTE: test for a bug in the multiprecision @@ -123,7 +123,7 @@ def test_basic(self): real = core.real - cf = make_cfunc([y * (x + z)], [x, y, z], fp_type=real, prec=128) + cf = cfunc([y * (x + z)], [x, y, z], fp_type=real, prec=128) self.assertEqual( cf([real(1, 128), real(2, 128), real(3, 128)]), copy(cf)([real(1, 128), real(2, 128), real(3, 128)]), @@ -135,7 +135,7 @@ def test_basic(self): def test_multi(self): import numpy as np - from . import make_cfunc, make_vars, sin, par, expression, core, time + from . import cfunc, make_vars, sin, par, expression, core, time from .core import _ppc_arch from .test import _get_eps, _allclose @@ -152,7 +152,7 @@ def test_multi(self): for fp_t in fp_types: with self.assertRaises(ValueError) as cm: - make_cfunc(func, vars=[y, x], fp_type=fp_t, batch_size=0) + cfunc(func, vars=[y, x], fp_type=fp_t, batch_size=0) self.assertTrue( "The batch size of a compiled function cannot be zero" in str(cm.exception) @@ -160,13 +160,13 @@ def test_multi(self): if fp_t == np.longdouble: with self.assertRaises(ValueError) as cm: - make_cfunc(func, vars=[y, x], fp_type=fp_t, batch_size=2) + cfunc(func, vars=[y, x], fp_type=fp_t, batch_size=2) self.assertTrue( "Batch sizes greater than 1 are not supported for this floating-point type" in str(cm.exception) ) - fn = make_cfunc(func, vars=[y, x], fp_type=fp_t) + fn = cfunc(func, vars=[y, x], fp_type=fp_t) with self.assertRaises(ValueError) as cm: fn( @@ -253,7 +253,7 @@ def test_multi(self): ) for nevals in range(0, 10): - fn = make_cfunc(func, vars=[y, x], fp_type=fp_t) + fn = cfunc(func, vars=[y, x], fp_type=fp_t) # NOTE: deterministic seeding. rng = np.random.default_rng(nevals) @@ -509,7 +509,7 @@ def test_multi(self): ) # Tests with no inputs. - fn = make_cfunc( + fn = cfunc( [expression(fp_t(3)) + par[1], par[0] + time], [], fp_type=fp_t ) @@ -587,7 +587,7 @@ def test_multi(self): ) ) - fn = make_cfunc( + fn = cfunc( [expression(fp_t(3)), expression(fp_t(4))], [], fp_type=fp_t ) @@ -613,7 +613,7 @@ def test_multi(self): # Test case in which there are no pars but a pars array is provided anyway, # with the correct shape. - fn = make_cfunc([x + y], [x, y], fp_type=fp_t) + fn = cfunc([x + y], [x, y], fp_type=fp_t) inputs = rng.random((2, nevals), dtype=float).astype(fp_t) eval_arr = fn(inputs=inputs, pars=np.zeros((0, nevals), dtype=fp_t)) @@ -644,11 +644,11 @@ def test_multi(self): # Check throwing behaviour with long double on PPC. if _ppc_arch: with self.assertRaises(NotImplementedError): - make_cfunc(func, vars=[y, x], fp_type=np.longdouble) + cfunc(func, vars=[y, x], fp_type=np.longdouble) def test_single(self): import numpy as np - from . import make_cfunc, make_vars, sin, par, expression, core, time + from . import cfunc, make_vars, sin, par, expression, core, time from .core import _ppc_arch from .test import _get_eps, _allclose @@ -668,7 +668,7 @@ def test_single(self): # etc., once we figure out how to test for them. Perhaps # examine the llvm states? for fp_t in fp_types: - fn = make_cfunc(func, [x, y], fp_type=fp_t) + fn = cfunc(func, [x, y], fp_type=fp_t) with self.assertRaises(ValueError) as cm: fn([fp_t(1), fp_t(2)]) @@ -843,7 +843,7 @@ def test_single(self): ) # Tests with no inputs. - fn = make_cfunc( + fn = cfunc( [expression(fp_t(3)) + par[1], par[0] + time], [], fp_type=fp_t ) @@ -870,7 +870,7 @@ def test_single(self): ) ) - fn = make_cfunc( + fn = cfunc( [expression(fp_t(3)), expression(fp_t(4)) + time], [], fp_type=fp_t ) @@ -904,7 +904,7 @@ def test_single(self): # Test case in which there are no pars but a pars array is provided anyway, # with the correct shape. - fn = make_cfunc([x + y], [x, y], fp_type=fp_t) + fn = cfunc([x + y], [x, y], fp_type=fp_t) eval_arr = fn(inputs=[fp_t(1), fp_t(2)], pars=np.zeros((0,), dtype=fp_t)) self.assertEqual(eval_arr[0], 3) diff --git a/heyoka/_test_elp2000.py b/heyoka/_test_elp2000.py index 0c66ab45..0f5735c9 100644 --- a/heyoka/_test_elp2000.py +++ b/heyoka/_test_elp2000.py @@ -13,11 +13,11 @@ class elp2000_test_case(_ut.TestCase): # Just a small basic test. def test_basic(self): - from . import make_cfunc + from . import cfunc from .model import elp2000_cartesian_e2000, elp2000_cartesian_fk5 sol = elp2000_cartesian_e2000(thresh=1e-5)[0] - cf = make_cfunc([sol], []) + cf = cfunc([sol], []) date = 2469000.5 self.assertAlmostEqual( @@ -25,7 +25,7 @@ def test_basic(self): ) sol = elp2000_cartesian_fk5(thresh=1e-5)[0] - cf = make_cfunc([sol], []) + cf = cfunc([sol], []) self.assertAlmostEqual( cf([], time=(date - 2451545.0) / 36525)[0], -361605.7668217605 diff --git a/heyoka/_test_mp.py b/heyoka/_test_mp.py index 3ffe0103..dacab607 100644 --- a/heyoka/_test_mp.py +++ b/heyoka/_test_mp.py @@ -16,21 +16,21 @@ def test_cfunc(self): if not hasattr(core, "real"): return - from . import real, make_cfunc, make_vars, sin, par, time + from . import real, cfunc, make_vars, sin, par, time import numpy as np x, y = make_vars("x", "y") func = [sin(x + y), x - par[0], x + y + par[1] + time] with self.assertRaises(ValueError) as cm: - make_cfunc(func, vars=[y, x], fp_type=real, batch_size=2) + cfunc(func, vars=[y, x], fp_type=real, batch_size=2) self.assertTrue( "Batch sizes greater than 1 are not supported for this floating-point type" in str(cm.exception) ) with self.assertRaises(ValueError) as cm: - make_cfunc(func, vars=[y, x], fp_type=real, prec=-1) + cfunc(func, vars=[y, x], fp_type=real, prec=-1) self.assertTrue( "An invalid precision value of -1 was passed to add_cfunc()" in str(cm.exception) @@ -38,7 +38,7 @@ def test_cfunc(self): prec = 237 - fn = make_cfunc(func, vars=[y, x], fp_type=real, prec=prec) + fn = cfunc(func, vars=[y, x], fp_type=real, prec=prec) # Initial simple test. inputs = np.array([real(1, prec), real(2, prec)]) diff --git a/heyoka/_test_vsop2013.py b/heyoka/_test_vsop2013.py index baaf4b65..2e919ef3 100644 --- a/heyoka/_test_vsop2013.py +++ b/heyoka/_test_vsop2013.py @@ -13,11 +13,11 @@ class vsop2013_test_case(_ut.TestCase): # Just a small basic test. def test_basic(self): - from . import make_cfunc + from . import cfunc from .model import vsop2013_elliptic, vsop2013_cartesian sol = vsop2013_elliptic(1, 1) - cf = make_cfunc([sol], []) + cf = cfunc([sol], []) date = 2411545.0 self.assertAlmostEqual( @@ -25,7 +25,7 @@ def test_basic(self): ) sol = vsop2013_cartesian(1, thresh=1e-8) - cf = make_cfunc([sol[0]], []) + cf = cfunc([sol[0]], []) self.assertAlmostEqual( cf([], time=(date - 2451545.0) / 365250)[0], 0.3493879042