diff --git a/camb/baseconfig.py b/camb/baseconfig.py index ba2974a6..27aa6e43 100644 --- a/camb/baseconfig.py +++ b/camb/baseconfig.py @@ -307,7 +307,7 @@ def AllocatableObjectArray(cls=None): class AllocatableArrayInt(_AllocatableArray): - _dtype = int + _dtype = np.int32 _ctype = c_int @@ -646,7 +646,7 @@ def __getstate__(self) -> dict: state = {} for field_name, field_type in self.get_all_fields(): obj = getattr(self, field_name) - if isinstance(obj, (ctypes.Array, np.ndarray)): + if isinstance(obj, (ctypes.Array, np.ndarray, FortranAllocatable)): state[field_name] = list(obj[:len(obj)]) elif isinstance(obj, ctypes.c_void_p): if obj.value is not None: diff --git a/camb/tests/camb_test.py b/camb/tests/camb_test.py index eb425214..cfc6b41e 100644 --- a/camb/tests/camb_test.py +++ b/camb/tests/camb_test.py @@ -451,6 +451,8 @@ def testSave(self): pars = camb.set_params(H0=67.5, ombh2=0.022, omch2=0.122, As=2e-9, ns=0.95, redshifts=[0.4, 31.5], kmax=0.1) pars.set_dark_energy(w=-0.7, wa=0.2, dark_energy_model='ppf') + from camb.sources import GaussianSourceWindow + pars.SourceWindows = [GaussianSourceWindow(), GaussianSourceWindow(redshift=1)] s = repr(pars) pars2 = eval(s) assert (repr(pars2) == s) @@ -458,6 +460,9 @@ def testSave(self): b = pickle.dumps(pars) pars2 = pickle.loads(b) assert (repr(pars2) == s) + pars2.InitPower = initialpower.SplinedInitialPower() + with self.assertRaises(TypeError): + repr(pars2) def testSigmaR(self): pars = camb.CAMBparams() diff --git a/docs/CAMBdemo.html b/docs/CAMBdemo.html index 59b59af1..bfa7d5af 100644 --- a/docs/CAMBdemo.html +++ b/docs/CAMBdemo.html @@ -14640,7 +14640,7 @@
-
Using CAMB 1.5.1 installed at c:\work\dist\git\camb\camb
+
Using CAMB 1.5.3 installed at c:\work\dist\git\camb\camb
 
@@ -15193,6 +15193,7 @@ pars = camb.read_ini('https://raw.githubusercontent.com/cmbant/CAMB/master/inifiles/planck_2018.ini') # for a local github installation you can just do # pars=camb.read_ini(os.path.join(camb_path,'inifiles','planck_2018.ini')) +# view parameter objects using print(), or use pickle or repr to save and restore print(pars) @@ -16498,7 +16499,7 @@ for z in zplot: plt.loglog(k, PK.P(z,k)) plt.xlim([1e-4,kmax]) -plt.xlabel('k Mpc') +plt.xlabel(r'k Mpc') plt.ylabel('$P_\Psi\, Mpc^{-3}$') plt.legend(['z=%s'%z for z in zplot]); @@ -18763,7 +18764,7 @@

Animations -
C:\Users\Antony\AppData\Local\Temp\ipykernel_29556\455262666.py:12: UserWarning: Data has no positive values, and therefore cannot be log-scaled.
+
C:\Users\Antony\AppData\Local\Temp\ipykernel_43884\455262666.py:12: UserWarning: Data has no positive values, and therefore cannot be log-scaled.
   ax.set_xlim(k[0], k[-1])