Skip to content

Commit

Permalink
Merge branch 'main' into 769-add-disable-for-dense-icon-button
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms authored Oct 28, 2024
2 parents 46a4b50 + 5a78d7f commit d0e1bbb
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 143 deletions.
2 changes: 0 additions & 2 deletions backend_py/primary/primary/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from primary.auth.auth_helper import AuthHelper
from primary.auth.enforce_logged_in_middleware import EnforceLoggedInMiddleware
from primary.middleware.add_process_time_to_server_timing_middleware import AddProcessTimeToServerTimingMiddleware
from primary.routers.correlations.router import router as correlations_router
from primary.routers.dev.router import router as dev_router
from primary.routers.explore import router as explore_router
from primary.routers.general import router as general_router
Expand Down Expand Up @@ -77,7 +76,6 @@ def custom_generate_unique_id(route: APIRoute) -> str:
app.include_router(inplace_volumetrics_router, prefix="/inplace_volumetrics", tags=["inplace_volumetrics"])
app.include_router(surface_router, prefix="/surface", tags=["surface"])
app.include_router(parameters_router, prefix="/parameters", tags=["parameters"])
app.include_router(correlations_router, prefix="/correlations", tags=["correlations"])
app.include_router(grid3d_router, prefix="/grid3d", tags=["grid3d"])
app.include_router(group_tree_router, prefix="/group_tree", tags=["group_tree"])
app.include_router(pvt_router, prefix="/pvt", tags=["pvt"])
Expand Down
Empty file.
65 changes: 0 additions & 65 deletions backend_py/primary/primary/routers/correlations/router.py

This file was deleted.

2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/parameters/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def get_parameter_names_and_description(
name=parameter.name,
descriptive_name=parameter.descriptive_name,
group_name=parameter.group_name,
is_numerical=parameter.is_numerical,
is_discrete=parameter.is_discrete,
)
for parameter in parameters
]
Expand Down
2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/parameters/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class EnsembleParameterDescription(BaseModel):
name: str
group_name: Optional[str] = None
descriptive_name: Optional[str] = None
is_numerical: bool
is_discrete: bool
62 changes: 0 additions & 62 deletions backend_py/primary/primary/services/parameter_correlations.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
name=parameter_name,
group_name=f"LOG10_{group_name}" if is_logarithmic else group_name,
is_logarithmic=is_logarithmic,
is_numerical=parameter_table.schema.field(table_column_name).type != pa.string,
is_discrete=_is_discrete_column(parameter_table.schema.field(table_column_name).type),
is_constant=len(set(parameter_table[table_column_name])) == 1,
descriptive_name=parameter_name,
values=parameter_table[table_column_name].to_numpy().tolist(),
Expand All @@ -150,6 +150,20 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
return ensemble_parameters


def _is_discrete_column(column_type: pa.DataType) -> bool:
"""Check if a column is discrete
Discrete parameter is defined as a parameter that is either a string or an integer
"""
return (
column_type == pa.string()
or column_type == pa.int64()
or column_type == pa.int32()
or column_type == pa.int16()
or column_type == pa.int8()
)


def _parameter_name_and_group_name_to_parameter_str(parameter_name: str, group_name: Optional[str]) -> str:
"""Convert a parameter name and group name to a parameter string"""
return f"{group_name}:{parameter_name}" if group_name else parameter_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnsembleParameter(BaseModel):

name: str
is_logarithmic: bool
is_numerical: bool
is_discrete: bool # values are string or integer
is_constant: bool # all values are equal
group_name: Optional[str] = None
descriptive_name: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/models/EnsembleParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export type EnsembleParameter = {
name: string;
is_logarithmic: boolean;
is_numerical: boolean;
is_discrete: boolean;
is_constant: boolean;
group_name: (string | null);
descriptive_name: (string | null);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/models/EnsembleParameterDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export type EnsembleParameterDescription = {
name: string;
group_name: (string | null);
descriptive_name: (string | null);
is_numerical: boolean;
is_discrete: boolean;
};

16 changes: 8 additions & 8 deletions frontend/src/framework/internal/EnsembleSetLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,27 @@ function buildParameterArrFromApiResponse(apiParameterArr: EnsembleParameter_api
const retParameterArr: Parameter[] = [];

for (const apiPar of apiParameterArr) {
if (apiPar.is_numerical) {
const retPar: ContinuousParameter = {
type: ParameterType.CONTINUOUS,
if (apiPar.is_discrete) {
const retPar: DiscreteParameter = {
type: ParameterType.DISCRETE,
name: apiPar.name,
groupName: apiPar.group_name,
description: apiPar.descriptive_name,
isConstant: apiPar.is_constant,
isLogarithmic: apiPar.is_logarithmic,
realizations: apiPar.realizations,
values: apiPar.values as number[],
values: apiPar.values,
};
retParameterArr.push(retPar);
} else {
const retPar: DiscreteParameter = {
type: ParameterType.DISCRETE,
const retPar: ContinuousParameter = {
type: ParameterType.CONTINUOUS,
name: apiPar.name,
groupName: apiPar.group_name,
description: apiPar.descriptive_name,
isConstant: apiPar.is_constant,
isLogarithmic: apiPar.is_logarithmic,
realizations: apiPar.realizations,
values: apiPar.values,
values: apiPar.values as number[],
};
retParameterArr.push(retPar);
}
Expand Down

0 comments on commit d0e1bbb

Please sign in to comment.