Commit 7533fbe8 authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Now that the minimum python version is 3.6, store integers as integers rather...

Now that the minimum python version is 3.6, store integers as integers rather than as floats in SharedArray.
parent b2a54d26
......@@ -9,6 +9,8 @@ compute them, such as the configuration, the observations, and the parameters
of the models.
import ctypes
from astropy.table import Table, Column
from .utils import SharedArray, get_info
......@@ -50,7 +52,7 @@ class ModelsManager(object):
self.flux = {band: SharedArray(size) for band in bandnames}
self.intprop = {prop: SharedArray(size) for prop in self.intpropnames}
self.extprop = {prop: SharedArray(size) for prop in self.extpropnames}
self.index = SharedArray(size)
self.index = SharedArray(size, ctypes.c_uint32)
def save(self, filename):
"""Save the fluxes and properties of all the models into a table.
......@@ -10,6 +10,7 @@ along with the names of the parameters, which are proportional to the mass,
etc. Each of these classes contain a merge() method that allows to combine
results of the analysis with different blocks of models.
import ctypes
from astropy.table import Table, Column
import numpy as np
......@@ -190,9 +191,7 @@ class BestResultsManager(object):
for prop in allextpropnames}
self.chi2 = SharedArray(nobs)
self.scaling = SharedArray(nobs)
# We store the index as a float to work around python issue #10746
self.index = SharedArray(nobs)
self.index = SharedArray(nobs, ctypes.c_uint32)
def flux(self):
......@@ -37,7 +37,7 @@ class SharedArray(object):
implementation and if new operations are done on these arrays, it may be
necessary to define them here.
def __init__(self, size):
def __init__(self, size, dtype=ctypes.c_double):
"""The RawArray is stored in raw, which is protected by a setter and
a getter. The array property returns raw as a regular Numpy array. It
is important to access both the RawArray and the Numpy array forms. The
......@@ -47,7 +47,7 @@ class SharedArray(object):
issue we selectively work with array or raw depending on whether the
operation is done with a slice or not.
self.raw = RawArray(ctypes.c_double, size)
self.raw = RawArray(dtype, size)
self.size = size
# By default RawArray initialises all the elements to 0. Setting them to
# np.nan is preferanble to in case for a reason some elements are never
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment