Skip to content
Snippets Groups Projects
Commit 4711d2b0 authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

prevent rmul data with units

parent 56511feb
No related branches found
No related tags found
1 merge request!260Masked array support
...@@ -4,7 +4,7 @@ Basic data transformation adapters. ...@@ -4,7 +4,7 @@ Basic data transformation adapters.
import numpy as np import numpy as np
from ..data.grid_spec import NoGrid from ..data.grid_spec import NoGrid
from ..data.tools import get_magnitude, get_units from ..data.tools import get_magnitude, get_units, quantify
from ..errors import FinamMetaDataError from ..errors import FinamMetaDataError
from ..sdk import Adapter from ..sdk import Adapter
from ..tools.log_helper import ErrorLogger from ..tools.log_helper import ErrorLogger
...@@ -139,9 +139,12 @@ class ValueToGrid(Adapter): ...@@ -139,9 +139,12 @@ class ValueToGrid(Adapter):
data-set for the requested time. data-set for the requested time.
""" """
value = self.pull_data(time, target) value = self.pull_data(time, target)
return np.full( return quantify(
self._info.grid.data_shape, get_magnitude(value), dtype=value.dtype np.full(
) * get_units(value) self._info.grid.data_shape, get_magnitude(value), dtype=value.dtype
),
get_units(value),
)
def _get_info(self, info): def _get_info(self, info):
up_info = info.copy_with(grid=NoGrid()) up_info = info.copy_with(grid=NoGrid())
...@@ -196,7 +199,7 @@ class GridToValue(Adapter): ...@@ -196,7 +199,7 @@ class GridToValue(Adapter):
""" """
grid = self.pull_data(time, target) grid = self.pull_data(time, target)
func_result = self.func(get_magnitude(grid)) * get_units(grid) func_result = quantify(self.func(get_magnitude(grid)), get_units(grid))
return func_result return func_result
......
...@@ -7,7 +7,7 @@ from datetime import datetime ...@@ -7,7 +7,7 @@ from datetime import datetime
from finam.interfaces import ComponentStatus from finam.interfaces import ComponentStatus
from ..data.grid_spec import NoGrid from ..data.grid_spec import NoGrid
from ..data.tools import UNITS, Info from ..data.tools import Info, quantify
from ..sdk import TimeComponent from ..sdk import TimeComponent
...@@ -151,7 +151,7 @@ class CsvReader(TimeComponent): ...@@ -151,7 +151,7 @@ class CsvReader(TimeComponent):
time = datetime.strptime(row[self._time_column], self._date_format) time = datetime.strptime(row[self._time_column], self._date_format)
out_data = { out_data = {
name: row[name] * UNITS.Unit(units) name: quantify(row[name], units)
for name, units in self._output_units.items() for name, units in self._output_units.items()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment